home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / internet-drafts / draft-ietf-imap-imap2bis-02.txt < prev    next >
Text File  |  1993-10-29  |  115KB  |  3,028 lines

  1.  
  2. Network Working Group                                       Mark Crispin
  3. Internet Draft: IMAP2bis                        University of Washington
  4. Obsoletes: RFC 1176, 1064                                   October 1993
  5. Document: internet-drafts/draft-ietf-imap-imap2bis-02.txt
  6.  
  7.  
  8.             INTERACTIVE MAIL ACCESS PROTOCOL - VERSION 2bis
  9.  
  10.  
  11. Status of this Memo
  12.  
  13.    This document is an Internet Draft.  Internet Drafts are working
  14.    documents of the Internet Engineering Task Force (IETF), its Areas,
  15.    and its Working Groups. Note that other groups may also distribute
  16.    working documents as Internet Drafts.
  17.  
  18.    Internet Drafts are draft documents valid for a maximum of six
  19.    months.  Internet Drafts may be updated, replaced, or obsoleted by
  20.    other documents at any time.  It is not appropriate to use Internet
  21.    Drafts as reference material or to cite them other than as a "working
  22.    draft" or "work in progress".  Please check the I-D abstract listing
  23.    contained in each Internet Draft directory to learn the current
  24.    status of any this or any other Internet Draft.
  25.  
  26.    This is a draft document of the IETF IMAP Working Group.  It is a
  27.    draft specification of the IMAP2bis protocol, based upon the
  28.    following earlier specifications: unpublished IMAP2bis.TXT document,
  29.    RFC 1176, and RFC 1064.  This document is not a complete or final
  30.    specification of the IMAP2bis protocol.
  31.  
  32.    Only matters that are believed to be uncontroversial, or issues that
  33.    are believed to be resolved, appear in this document.  The entirety
  34.    of this document is subject to change and extension.  A list of open
  35.    issues may be found in the file mail/imap.unresolved on Internet site
  36.    ftp.CAC.Washington.EDU.
  37.  
  38.    A version of this draft document will be submitted to the RFC editor
  39.    as a Proposed Standard for the Internet Community.  Discussion and
  40.    suggestions for improvement are requested.  This document will expire
  41.    before 31 March 1994.  Distribution of this draft is unlimited.
  42.    Comments are solicited and should be sent to imap@CAC.Washington.EDU.
  43.  
  44.  
  45. Introduction
  46.  
  47.    The Interactive Mail Access Protocol, Version 2bis (IMAP2bis) allows
  48.    a client to access and manipulate electronic mail on a server.
  49.    IMAP2bis is designed to permit manipulations of remote mailboxes as
  50.  
  51.  
  52.  
  53. Crispin                                                         [Page 1]
  54.  
  55. Internet Draft                  IMAP2bis                October 27, 1993
  56.  
  57.  
  58.    if they were local.  IMAP2bis includes operations for creating,
  59.    deleting, and renaming mailbox folders; checking for new mail;
  60.    permanently removing messages; setting and clearing flags; RFC 822
  61.    and MIME parsing; searching; and selective fetching of message
  62.    attributes, texts, and portions thereof.
  63.  
  64.    IMAP2bis does not specify a means of posting mail; this function is
  65.    handled by a mail transfer protocol such as SMTP (RFC 821).
  66.  
  67.    IMAP2bis assumes a reliable data stream such as provided by TCP.
  68.    When TCP is used, an IMAP2bis server listens on port 143.
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109. Crispin                                                         [Page 2]
  110.  
  111. Internet Draft                  IMAP2bis                October 27, 1993
  112.  
  113.  
  114. System Model and Philosophy
  115.  
  116.    There are three fundamental models of client/server email: offline,
  117.    online, and disconnected use.  IMAP2bis can be used in any one of
  118.    these three models.
  119.  
  120.    The offline model is the most familiar form of client/server email
  121.    today, and is used by protocols such as POP-3 (RFC 1225) and UUCP.
  122.    In this model, a client application periodically connects to a
  123.    server.  It downloads all the pending messages to the client machine
  124.    and deletes these from the server.  Thereafter, all mail processing
  125.    is local to the client.  This model is store-and-forward; it moves
  126.    mail on demand from an intermediate server (maildrop) to a single
  127.    destination machine.
  128.  
  129.    The online model is most commonly used with remote filesystem
  130.    protocols such as NFS.  In this model, a client application
  131.    manipulates mailbox data on a server machine.  A connection to the
  132.    server is maintained throughout the session.  No mailbox data are
  133.    kept on the client; the client retrieves data from the server as is
  134.    needed.  IMAP2bis introduces a form of the online model that requires
  135.    considerably less network bandwidth than a remote filesystem
  136.    protocol, and provides the opportunity for using the server for CPU
  137.    or I/O intensive functions such as parsing and searching.
  138.  
  139.    The disconnected use model is a hybrid of the offline and online
  140.    models, and is used by protocols such as PCMAIL (RFC 1056).  In this
  141.    model, a client user downloads some set of messages from the server,
  142.    manipulates them offline, then at some later time uploads the
  143.    changes.  The server remains the authoritative repository of the
  144.    messages.  The problems of synchronization (particularly when
  145.    multiple clients are involved) are handled through the means of
  146.    unique identifiers for each message.
  147.  
  148.    Each of these models have their own strengths and weaknesses:
  149.  
  150.       Feature                               Offline Online  Disc
  151.       -------                               ------- ------  ----
  152.       Can use multiple clients               NO      YES     YES
  153.       Minimum use of server connect time     YES     NO      YES
  154.       Minimum use of server resources        YES     NO      NO
  155.       Minimum use of client disk resources   NO      YES     NO
  156.       Multiple remote mailboxes              NO      YES     YES
  157.       Fast startup                           NO      YES     NO
  158.       Mail processing when not online        YES     NO      YES
  159.  
  160.    Although IMAP2bis was originally designed to accommodate the online
  161.    model, it can support the other two models as well.  This makes
  162.  
  163.  
  164.  
  165. Crispin                                                         [Page 3]
  166.  
  167. Internet Draft                  IMAP2bis                October 27, 1993
  168.  
  169.  
  170.    possible the creation of clients that can be used in any of the three
  171.    models.  For example, a user may wish to switch between the online
  172.    and disconnected models on a regular basis (e.g. owing to travel).
  173.  
  174.    IMAP2bis is designed to transmit message data on demand, and to
  175.    provide the facilities necessary for a client to decide what data it
  176.    needs at any particular time.  There is generally no need to do a
  177.    wholesale transfer of an entire mailbox or even of the complete text
  178.    of a message.  This makes a difference in situations where the
  179.    mailbox is large, or when the link to the server is slow.
  180.  
  181.    More specifically, IMAP2bis supports server-based RFC 822 and MIME
  182.    processing.  With this information, it is possible for a client to
  183.    determine in advance whether it wishes to retrieve a particular
  184.    message or part of a message.  For example, a user connected to an
  185.    IMAP2bis server via a dialup link can determine that a message has a
  186.    2000 byte text segment and a 40 megabyte video segment, and elect to
  187.    fetch only the text segment.
  188.  
  189.    In IMAP2bis, the client/server relationship lasts only for the
  190.    duration of the TCP connection, and mailbox state is maintained on
  191.    the server.  There is no registration of clients.  Except for any
  192.    unique identifiers used in disconnected use operation, the client
  193.    initially has no knowledge of mailbox state and learns it from the
  194.    IMAP2bis server when a mailbox is selected.  This initial transfer is
  195.    minimal; the client requests additional state data as it needs.
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221. Crispin                                                         [Page 4]
  222.  
  223. Internet Draft                  IMAP2bis                October 27, 1993
  224.  
  225.  
  226. The Protocol
  227.  
  228.    The IMAP2bis protocol consists of a sequence of client commands and
  229.    server responses, with server data interspersed between the
  230.    responses.  Unlike most Internet protocols, commands and responses
  231.    are tagged.  That is, a command begins with a unique identifier
  232.    (typically a short alphanumeric sequence such as a Lisp "gensym"
  233.    function would generate e.g., A0001, A0002, etc.) called a tag.  The
  234.    response to the command is given the same tag from the server.
  235.  
  236.    Additionally, the server may send an arbitrary amount of "unsolicited
  237.    data".  Unsolicited data is identified by the special reserved tag of
  238.    "*".  The unsolicited data mechanism transmits most data in IMAP2bis.
  239.    The term "unsolicited data" suggests that the data may have been
  240.    transmitted without any explicit request by the client for that data.
  241.    No distinction is made in IMAP2bis between data transmitted as a
  242.    result of a client command and data that are unilaterally transmitted
  243.    by the server.  One form of unilaterally transmitted data that
  244.    commonly occurs is an alert of a change to the mailbox made by some
  245.    process other than the IMAP2bis client or server; for example,
  246.    changes in the size of the mailbox (new mail) or in the status of
  247.    individual messages.
  248.  
  249.    There is another special reserved tag, "+", discussed below.
  250.  
  251.    The server must be listening for a connection.  When a connection is
  252.    opened the server sends a greeting message and then waits for
  253.    commands.  This greeting is either a PREAUTH (meaning that the user
  254.    has already been identified and authenticated by an external
  255.    mechanism such as rsh) or OK (meaning that the user is not yet
  256.    authenticated) unsolicited response.  The server may also send a BYE
  257.    unsolicited response and close the connection if it rejects the
  258.    connection.
  259.  
  260.    The client opens a connection and waits for the greeting.  The client
  261.    must not send any commands until it has received the greeting from
  262.    the server.
  263.  
  264.    Once the greeting has been received, the client may begin sending
  265.    commands.  It is not under any obligation to wait for a server
  266.    response to a command before sending another command, subject to the
  267.    constraints of underlying flow control.  When commands are received
  268.    the server acts on them and responds with command responses, often
  269.    interspersed with data.
  270.  
  271.    In general, the command responses do not themselves contain the
  272.    requested data.  Instead, they indicate the completion status of the
  273.    request.  There are three fundamental responses: success (OK), error
  274.  
  275.  
  276.  
  277. Crispin                                                         [Page 5]
  278.  
  279. Internet Draft                  IMAP2bis                October 27, 1993
  280.  
  281.  
  282.    (NO), request faulty or not understood (BAD).  The effect of a
  283.    command can not be considered complete until a command response with
  284.    a tag matching the command is received from the server.
  285.  
  286.    It is not required that a server process a command to completion
  287.    before beginning processing of the next command, except when the
  288.    processing of the previous command may affect the results of the next
  289.    command by changing the state of the current mailbox.  This has
  290.    certain other effects; for example, this implies that an EXPUNGE
  291.    response can not be transmitted as part of a response to a command
  292.    that uses sequence numbers, because EXPUNGE results in message
  293.    numbers being changed.
  294.  
  295.    Client implementations should update their local cache of data with
  296.    any received unsolicited data, regardless of whether or not the
  297.    client expected that data.  Unlike command completion responses, data
  298.    are not necessarily associated with a specific command.  The tagged
  299.    command completion response signals that the client cache is now
  300.    updated with the results of the corresponding command.
  301.  
  302.    If authentication has not yet been completed, it must now be done via
  303.    the LOGIN command before any access to data is permitted.  The only
  304.    permitted commands before successful authentication are LOGIN, NOOP,
  305.    and LOGOUT.  See the section below on authentication.
  306.  
  307.    Once authenticated, the client must send a mailbox selection command
  308.    to access the desired mailbox; no mailbox is selected by default.
  309.    Mailbox names are implementation dependent.  However, the word
  310.    "INBOX" must be implemented to mean the primary or default mailbox
  311.    for this user, independent of any other server semantics.  It is
  312.    permitted for a server not to have an INBOX if there is no concept of
  313.    a primary or default mailbox for this user.  The name "INBOX" MUST
  314.    NOT be used for any other purpose.
  315.  
  316.    On a successful selection, the server will send a list of valid
  317.    flags, number of messages, and number of messages arrived since last
  318.    access for this mailbox as unsolicited data, followed by an OK
  319.    response.  The client may close access to this mailbox and access a
  320.    different one with another selection command.
  321.  
  322.    Several flags are predefined in IMAP2bis.  All IMAP2bis flags begin
  323.    with a backslash ("\") character.  Servers MUST, at a minimum,
  324.    support all the predefined flags in this specification.  In addition,
  325.    a server may also have some implementation-defined per-mailbox flags
  326.    (called, for historical reasons, "keywords") that do not begin with
  327.    backslash.  Clients should use the information from the server's
  328.    FLAGS response at message selection to determine what flags the
  329.    server supports.
  330.  
  331.  
  332.  
  333. Crispin                                                         [Page 6]
  334.  
  335. Internet Draft                  IMAP2bis                October 27, 1993
  336.  
  337.  
  338.    The client requests mailbox data with FETCH commands, and receives it
  339.    via the unsolicited data mechanism.  Three major categories of
  340.    mailbox data exist.
  341.  
  342.    The first category is data that are associated with a message as an
  343.    entity in the mailbox.  There are now four such items of data: the
  344.    "internal date", the "RFC 822 size", the "flags", and the "unique
  345.    id".  The internal date is the date and time that the message was
  346.    placed in the mailbox.  The RFC 822 size is the size in octets of the
  347.    message, expressed as an RFC 822 text string.  The flags are a list
  348.    of status flags associated with the message.  The unique id is an
  349.    identifier that is guaranteed to refer to this message and to none
  350.    other in the mailbox and that, unlike IMAP2bis sequence numbers,
  351.    persists across sessions.
  352.  
  353.    The second category is data that describe the composition and
  354.    delivery information of a message; that is, information such as the
  355.    message sender, recipient lists, message-ID, subject, MIME structure,
  356.    etc.  This is the information that is stored in the RFC 822 and MIME
  357.    headers.  In IMAP2bis, the RFC 822 header information that may be
  358.    fetched is called the "envelope structure" (not to be confused with
  359.    SMTP envelopes).  Similarly, the MIME header information that may be
  360.    fetched is called the "body structure".  A client can use the parsed
  361.    envelope and body structures and not worry about having to do its own
  362.    RFC 822 or MIME parsing.
  363.  
  364.    The third category is textual data, some of which are intended for
  365.    direct human viewing.  IMAP2bis defines six such items:
  366.    RFC822.HEADER, RFC822.HEADER.LINES, RFC822.HEADER.LINES.NOT,
  367.    RFC822.TEXT, RFC822, and MIME body parts.  It is possible to fetch an
  368.    individual MIME body part of a message without fetching any other
  369.    data associated with the message.
  370.  
  371.    A simple client can "FETCH RFC822" to get the entire message without
  372.    any processing.  A more advanced client might fetch some combination
  373.    of the first and second categories of data for use as a presentation
  374.    menu.  Then, when the user wishes to read a particular message, it
  375.    will fetch the appropriate texts.
  376.  
  377.    Data structures in IMAP2bis are represented as an S-expression list
  378.    similar to that used in the Lisp programming language.  An S-
  379.    expression consists of a sequence of data items delimited by space
  380.    and bounded at each end by parentheses.  An S-expression may itself
  381.    contain other S-expressions, using parentheses to indicate nesting.
  382.    S-expression syntax was chosen because it provides a concise and
  383.    precise means of expressing nested data (e.g. MIME structures).
  384.  
  385.    The client can alter certain data with a STORE command.  As an
  386.  
  387.  
  388.  
  389. Crispin                                                         [Page 7]
  390.  
  391. Internet Draft                  IMAP2bis                October 27, 1993
  392.  
  393.  
  394.    example, a message is deleted from a mailbox by setting the \Deleted
  395.    flag with a STORE command.
  396.  
  397.    Other client operations that can be done to a mailbox include copying
  398.    messages to other mailboxes, permanently removing deleted messages,
  399.    checking for updated mailbox state, and searching for messages that
  400.    match certain criteria.  It is also possible to select a different
  401.    mailbox, create a new mailbox, rename an existing mailbox, or delete
  402.    an existing mailbox.
  403.  
  404.    The client should end the session with the LOGOUT command.  The
  405.    server returns a "BYE" followed by an "OK", at which point both the
  406.    client and the server close the connection.  If the client closes the
  407.    network connection without a LOGOUT command, the server should do its
  408.    normal logout procedures without attempting any further interaction
  409.    with the client.
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445. Crispin                                                         [Page 8]
  446.  
  447. Internet Draft                  IMAP2bis                October 27, 1993
  448.  
  449.  
  450. Authentication
  451.  
  452.    Pre-authentication is only possible when the connection to the
  453.    IMAP2bis service is made through some link protocol that provides its
  454.    own authentication mechanism.  It is not used with a TCP connection
  455.    to port 143.
  456.  
  457.    An example of pre-authentication is the BSD "RSH" protocol, that
  458.    provides authentication through a "trusted host" facility.  Another
  459.    example would be a manual invocation of an IMAP2bis server from a
  460.    logged-in timesharing job.
  461.  
  462.    A pre-authenticated IMAP2bis server should recognize that
  463.    authentication has already happened, and enter the post-login state.
  464.    In its greeting message, it should use the unsolicited response
  465.    "PREAUTH" instead of "OK" to indicate that external authentication
  466.    has taken place.
  467.  
  468.    This is an example of a pre-authentication scenario.  In this and all
  469.    other examples in this document, S: indicates server dialog and C:
  470.    indicates client dialog.
  471.  
  472.            S: * PREAUTH IMAP2bis Server pre-authenticated as user "Smith"
  473.            C: A001 SELECT INBOX
  474.            S: * FLAGS (\Answered \Flagged \Deleted \Seen)
  475.            S: * 19 EXISTS
  476.            S: * 2 RECENT
  477.            S: A001 OK SELECT complete
  478.  
  479.    A connection that is not pre-authenticated is constrained to using
  480.    the LOGIN command for establishing authentication.  Authentication
  481.    via the LOGIN command is with either a user name and password pair,
  482.    or with an user identifier and Kerberos authenticator.  See the
  483.    description of the LOGIN command for more details.
  484.  
  485.    Servers may allow non-authenticated access to certain mailboxes or
  486.    bulletin boards.  The convention is to use a LOGIN command with the
  487.    userid "anonymous".  A password is still required.  It is
  488.    implementation-dependent what requirements, if any, are placed on the
  489.    password and what access restrictions are placed on anonymous users.
  490.  
  491.    Implementations are NOT required to support pre-authentication,
  492.    Kerberos authentication, or the anonymous convention.
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501. Crispin                                                         [Page 9]
  502.  
  503. Internet Draft                  IMAP2bis                October 27, 1993
  504.  
  505.  
  506. Definitions of Commands and Responses
  507.  
  508.      Summary of Defined Commands and Responses
  509.  
  510.        Commands                            ||  Responses
  511.        --------                            ||  -------
  512.        tag NOOP                            ||  tag OK resp_text
  513.        tag LOGIN user password             ||  tag NO resp_text
  514.        tag LOGOUT                          ||  tag BAD resp_text
  515.        tag CREATE mailbox                  ||  * PREAUTH resp_text
  516.        tag DELETE mailbox                  ||  * OK resp_text
  517.        tag RENAME old_mailbox new_mailbox  ||  * NO resp_text
  518.        tag FIND MAILBOXES pattern          ||  * BAD resp_text
  519.        tag FIND ALL.MAILBOXES pattern      ||  * BYE resp_text
  520.        tag FIND BBOARDS pattern            ||  * MAILBOX mstring
  521.        tag FIND ALL.BBOARDS pattern        ||  * BBOARD mstring
  522.        tag SUBSCRIBE MAILBOX mailbox       ||  * SEARCH 1#number
  523.        tag UNSUBSCRIBE MAILBOX mailbox     ||  * FLAGS flag_list
  524.        tag SUBSCRIBE BBOARD mailbox        ||  * number EXISTS
  525.        tag UNSUBSCRIBE BBOARD mailbox      ||  * number RECENT
  526.        tag SELECT mailbox                  ||  * number EXPUNGE
  527.        tag EXAMINE mailbox                 ||  * number FETCH data
  528.        tag BBOARD mailbox                  ||  * number COPY
  529.        tag CHECK                           ||  * number STORE data
  530.        tag EXPUNGE                         ||  + text
  531.        tag COPY sequence mailbox           ||
  532.        tag APPEND mailbox 0#flag literal   ||
  533.        tag FETCH sequence data             ||
  534.        tag PARTIAL msgno data start count  ||
  535.        tag STORE sequence data value       ||
  536.        tag UID AFTER uniqueid              ||
  537.        tag UID COPY sequence mailbox       ||
  538.        tag UID FETCH sequence data         ||
  539.        tag UID STORE sequence data value   ||
  540.        tag SEARCH search_program           ||
  541.        tag x_command arguments             ||
  542.  
  543.    Note: there is no pairing between commands and responses on the same
  544.    line.  Any command may result in any number (including none at all)
  545.    of any of responses beginning with "*" (referred to as "unsolicited
  546.    data"), followed by one tagged response.
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557. Crispin                                                        [Page 10]
  558.  
  559. Internet Draft                  IMAP2bis                October 27, 1993
  560.  
  561.  
  562. Commands
  563.  
  564.    If, during the execution of any command, the server observes that the
  565.    mailbox size has changed, the server should output an unsolicited
  566.    EXISTS and RECENT response reflecting the changed size to alert the
  567.    client.  Similarly, any observed change in message status should
  568.    cause an unsolicited FETCH response with the new flag data.
  569.  
  570.  
  571.    tag NOOP
  572.  
  573.       The NOOP command returns an OK to the client.  By itself, it does
  574.       nothing else.  However, since any command can return a status
  575.       update as unsolicited data, this command can be used to poll for
  576.       new mail or for message status updates.
  577.  
  578.       Another possible use of this command is for the client to "ping"
  579.       the server so that the client and server know that each other are
  580.       still alive.  This is useful with servers that have an inactivity
  581.       autologout timer.
  582.  
  583.  
  584.    tag LOGIN user password
  585.  
  586.       The LOGIN command identifies the user to the server and carries
  587.       the password authenticating this user.  This information is used
  588.       by the server to control access to the mailboxes.
  589.  
  590.       EXAMPLE:  a001 LOGIN SMITH SESAME
  591.       logs in as user SMITH with password SESAME.
  592.  
  593.       If a server supports authentication via Kerberos, it may accept
  594.       the string "@KERBEROS:" followed by the hexadecimal representation
  595.       of a Kerberos authenticator.
  596.  
  597.       EXAMPLE: The following is a Kerberos login scenario (note that the
  598.       line breaks in the sample authenticator are for editorial clarity
  599.       and are not in a real authenticator):
  600.  
  601.          S: * OK Kerberos IMAP2bis Server
  602.          C: a001 LOGIN smith @KERBEROS:040700414e445245572e434d552e4544550
  603.             038202c868f3890b377fc8266acc1bedb96b80d3fa76489898e74cd1c952dc
  604.             4003ea3428f29f1c470016cf5adc22f939e6deff2747254c1815d5b0b90d4c
  605.             5a2cba21eb0abe32f9acbf568d751bf4cc13f5ba4e6d82c638a8b5421
  606.          S: a001 OK [df84a4cb8323454f] Login OK via Kerberos
  607.  
  608.       The token in the brackets in the OK response is the Kerberos
  609.       authentication response, encrypted with the session key in network
  610.  
  611.  
  612.  
  613. Crispin                                                        [Page 11]
  614.  
  615. Internet Draft                  IMAP2bis                October 27, 1993
  616.  
  617.  
  618.       byte order and an incremented checksum as in the usual Kerberos
  619.       procedure.
  620.  
  621.  
  622.    tag LOGOUT
  623.  
  624.       The LOGOUT command informs the server that the client is done with
  625.       the session.  The server should send an unsolicited BYE response
  626.       before the (tagged) OK response, and then close the network
  627.       connection.
  628.  
  629.  
  630.    Mailbox manipulation commands: CREATE, DELETE, RENAME
  631.  
  632.    These commands permit the manipulation of entire mailboxes.
  633.  
  634.       tag CREATE mailbox
  635.  
  636.          The CREATE command creates a mailbox with the given name.  This
  637.          command returns an OK response only if a new mailbox with that
  638.          name has been created.  It is an error to attempt to create a
  639.          mailbox with a name that refers to an extant mailbox.  Any
  640.          error in creation will return a NO response.
  641.  
  642.          Creating INBOX is not permitted.  If there is a primary or
  643.          default mailbox for this user, it MUST exist and be called
  644.          INBOX.
  645.  
  646.  
  647.       tag DELETE mailbox
  648.  
  649.          The DELETE command deletes a mailbox with the given name.  This
  650.          command returns an OK response only if a mailbox with that name
  651.          has been deleted.  It is an error to attempt to delete a
  652.          mailbox name that does not exist.  Any error in deletion will
  653.          return a NO response.
  654.  
  655.          A server SHOULD NOT attempt to test that a mailbox is empty
  656.          before permitting deletion; this would prevent the deletion of
  657.          a mailbox that for some reason can not be opened or expunged,
  658.          leaving to possible denial of service problems.  Any such
  659.          checking should be left to the discretion of the client.
  660.  
  661.          Deleting INBOX is not permitted.
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669. Crispin                                                        [Page 12]
  670.  
  671. Internet Draft                  IMAP2bis                October 27, 1993
  672.  
  673.  
  674.       tag RENAME old_mailbox new_mailbox
  675.  
  676.          The RENAME command changes the name of a mailbox.  This command
  677.          returns an OK response only if a mailbox with the old name
  678.          exists and has been successfully renamed to the new name.  It
  679.          is an error to attempt to rename with an old mailbox name that
  680.          does not exist or a new mailbox name that already exists.  Any
  681.          error in renaming will return a NO response.
  682.  
  683.          Renaming INBOX is permitted.  A new, empty INBOX is created in
  684.          its place.
  685.  
  686.  
  687.    FIND commands
  688.  
  689.    The FIND commands return some set of unsolicited MAILBOX or BBOARD
  690.    replies, depending on the type of FIND, that have as their value a
  691.    single mailbox name.
  692.  
  693.    Three wildcard characters are defined in the pattern argument.  "*"
  694.    specifies any number (including zero) characters may match at this
  695.    position.  "%" and "?"  specify a single character may match at this
  696.    position.  For example, FOO*BAR will match FOOBAR, FOOD.ON.THE.BAR
  697.    and FOO.BAR, whereas FOO%BAR and FOO?BAR match only FOO.BAR.  "*"
  698.    will match all mailboxes.
  699.  
  700.  
  701.       tag FIND MAILBOXES pattern
  702.  
  703.          The FIND MAILBOXES command accepts as an argument a pattern
  704.          (including wildcards) that specifies some set of mailbox names
  705.          that the user has declared as being "active" or "subscribed".
  706.          The exact meaning of this is implementation-dependent, since
  707.          the concept of a set of "active" or "subscribed" mailboxes that
  708.          is preserved across sessions may not be meaningful for a
  709.          particular server or server implementation.  If the SUBSCRIBE
  710.          MAILBOX and UNSUBSCRIBE MAILBOX commands are implemented then
  711.          this command returns the list manipulated by those commands.
  712.  
  713.          EXAMPLE:  C: A002 FIND MAILBOXES *
  714.                    S: * MAILBOX FOOBAR
  715.                    S: * MAILBOX GENERAL
  716.                    S: A002 OK FIND completed
  717.  
  718.  
  719.       tag FIND ALL.MAILBOXES pattern
  720.  
  721.          The FIND ALL.MAILBOXES command is similar to FIND MAILBOXES;
  722.  
  723.  
  724.  
  725. Crispin                                                        [Page 13]
  726.  
  727. Internet Draft                  IMAP2bis                October 27, 1993
  728.  
  729.  
  730.          however, it should return a complete list of all mailboxes
  731.          available to the user.  Data are returned as in FIND MAILBOXES.
  732.  
  733.          The special name INBOX is included in the output from FIND
  734.          ALL.MAILBOXES unless INBOX is not supported by this server or
  735.          for this user.  The criteria for omitting INBOX is whether
  736.          SELECT INBOX will return failure; it is not relevant whether
  737.          the user's real INBOX resides on this or some other server.
  738.          FIND MAILBOXES and SUBSCRIBE MAILBOX provide a mechanism for
  739.          the user to identify that this is his or her real INBOX.
  740.  
  741.          FIND ALL.MAILBOXES must, at least, return all the mailbox names
  742.          that are returned by FIND MAILBOXES.
  743.  
  744.          The exact meaning of this is implementation-dependent, since
  745.          the concept of a bounded or deterministic set of "mailboxes
  746.          available to the user" may not be meaningful for a particular
  747.          server or server implementation.
  748.  
  749.  
  750.       tag FIND BBOARDS pattern
  751.  
  752.          The FIND BBOARDS command accepts as an argument a pattern that
  753.          specifies some set of bulletin board names that the user has
  754.          declared as being "active" or "subscribed".  Wildcards are
  755.          permitted as in FIND MAILBOXES.
  756.  
  757.          The FIND BBOARDS command will return some set of unsolicited
  758.          BBOARD replies that have as their value a single bulletin board
  759.          name.
  760.  
  761.          EXAMPLE:  C: A002 FIND BBOARDS *
  762.                    S: * BBOARD FOOBAR
  763.                    S: * BBOARD GENERAL
  764.                    S: A002 OK FIND completed
  765.  
  766.          The exact meaning of this is implementation-dependent, since
  767.          the concept of a set of "active" or "subscribed" bboards that
  768.          is preserved across sessions may not be meaningful for a
  769.          particular server or server implementation.  If the SUBSCRIBE
  770.          BBOARD and UNSUBSCRIBE BBOARD commands are implemented then
  771.          this command returns the list manipulated by those commands.
  772.  
  773.  
  774.       tag FIND ALL.BBOARDS pattern
  775.  
  776.          The FIND ALL.BBOARDS command is similar to FIND BBOARDS;
  777.          however, it should return a complete list of all bulletin
  778.  
  779.  
  780.  
  781. Crispin                                                        [Page 14]
  782.  
  783. Internet Draft                  IMAP2bis                October 27, 1993
  784.  
  785.  
  786.          boards available to the user.  Data are returned as in FIND
  787.          BBOARDS.
  788.  
  789.          FIND ALL.BBOARDS must, at least, return all the bboard names
  790.          that are returned by FIND BBOARDS.
  791.  
  792.          The exact meaning of this is implementation-dependent, since
  793.          the concept of a bounded or deterministic set of "bboards
  794.          available to the user" may not be meaningful for a particular
  795.          server or server implementation.
  796.  
  797.  
  798.    Subscription commands
  799.  
  800.    These commands permit the manipulation of mailbox or bulletin board
  801.    subscriptions.  Subscription status should be preserved between
  802.    sessions.
  803.  
  804.  
  805.       tag SUBSCRIBE MAILBOX mailbox
  806.  
  807.          The SUBSCRIBE MAILBOX command adds the specified mailbox name
  808.          to the list of "active" or "subscribed" mailboxes as returned
  809.          by the FIND MAILBOXES command.  This command returns an OK
  810.          response only if the subscription is successful.
  811.  
  812.  
  813.       tag UNSUBSCRIBE MAILBOX mailbox
  814.  
  815.          The UNSUBSCRIBE MAILBOX command removes the specified mailbox
  816.          name from the list of "active" or "subscribed" mailboxes as
  817.          returned by the FIND MAILBOXES command.  This command returns
  818.          an OK response only if the unsubscription is successful.
  819.  
  820.  
  821.       tag SUBSCRIBE BBOARD bboard
  822.  
  823.          The SUBSCRIBE BBOARD command adds the specified mailbox name to
  824.          the list of "active" or "subscribed" bulletin boards as
  825.          returned by the FIND BBOARDS command.  This command returns an
  826.          OK response only if the subscription is successful.
  827.  
  828.  
  829.       tag UNSUBSCRIBE BBOARD bboard
  830.  
  831.          The UNSUBSCRIBE BBOARD command removes the specified mailbox
  832.          name from the list of "active" or "subscribed" bulletin boards
  833.          as returned by the FIND BBOARDS command.  This command returns
  834.  
  835.  
  836.  
  837. Crispin                                                        [Page 15]
  838.  
  839. Internet Draft                  IMAP2bis                October 27, 1993
  840.  
  841.  
  842.          an OK response only if the unsubscription is successful.
  843.  
  844.  
  845.    tag SELECT mailbox
  846.  
  847.       This command selects a particular mailbox.  The server must check
  848.       that the user is permitted read access to this mailbox.  Before
  849.       returning an OK to the client, the server must send the following
  850.       unsolicited data to the client:
  851.          FLAGS        mailbox's defined flags
  852.          <n> EXISTS   the number of messages in the mailbox
  853.          <n> RECENT   the number of messages added to the mailbox since the
  854.                       previous time this mailbox was read
  855.       to define the initial state of the mailbox at the client.  If it
  856.       can not be determined which messages were added since the previous
  857.       time a mailbox was read, then all messages SHOULD be considered
  858.       recent.  An example of this is if no "last read" time information
  859.       is available or a read-only mailbox that does not permit a change
  860.       of "last read" time.
  861.  
  862.       Multiple selection commands are permitted in a session.  The
  863.       previous mailbox is automatically deselected when a new selection
  864.       is made.  If concurrent access to multiple mailboxes is desired,
  865.       the client should open additional sessions as needed.
  866.  
  867.       The mailbox name INBOX is a special name reserved to mean "the
  868.       primary mailbox for this user on this server".  The format of
  869.       other mailbox names is implementation dependent.
  870.  
  871.       The text of an OK response to the SELECT command should begin with
  872.       either "[READ-ONLY]" or "[READ-WRITE]" to show the mailbox's
  873.       access status.
  874.  
  875.  
  876.    tag EXAMINE mailbox
  877.  
  878.       The EXAMINE command is similar to SELECT, and returns the same
  879.       output; however, the selected mailbox is identified as read-only
  880.       and no changes are permitted to this mailbox.  EXAMINE has the
  881.       same mailbox namespace as SELECT.
  882.  
  883.  
  884.    tag BBOARD mailbox
  885.  
  886.       The BBOARD command is similar to SELECT, and returns the same
  887.       output.  Its argument is a shared mailbox (bulletin board) name
  888.       instead of an ordinary mailbox.  There is no requirement that the
  889.       namespace for BBOARD be the same as that for SELECT and EXAMINE.
  890.  
  891.  
  892.  
  893. Crispin                                                        [Page 16]
  894.  
  895. Internet Draft                  IMAP2bis                October 27, 1993
  896.  
  897.  
  898.       BBOARD also differs from EXAMINE in that it may allow changes
  899.       (e.g. marking a message as seen or deleted) to a mailbox; the
  900.       exact handling of this is implementation dependent.
  901.  
  902.  
  903.    tag CHECK
  904.  
  905.       The CHECK command requests a checkpoint of the mailbox.  CHECK may
  906.       cause an operation that may take a non-instantaneous amount of
  907.       real-time to complete.  The exact meaning of a checkpoint is
  908.       implementation-dependent.  Possible interpretations include
  909.       forcing an update of the server's disk of all changes made to the
  910.       selected mailbox, rescanning of the entire mailbox, etc.  If an
  911.       implementation has no such considerations, CHECK should be
  912.       equivalent to NOOP.
  913.  
  914.       CHECK should NOT be used to poll for new mail; new mail checking
  915.       happens implicitly as part of every command.  NOOP should be used
  916.       for any new mail polling.  CHECK should NOT be used to get the
  917.       current size of the mailbox; there is no guarantee that CHECK will
  918.       cause an EXISTS or RECENT unsolicited response.
  919.  
  920.  
  921.    tag EXPUNGE
  922.  
  923.       The EXPUNGE command permanently removes all messages with the
  924.       \Deleted flag set from the currently selected mailbox.  Before
  925.       returning an OK to the client, for each message that is removed,
  926.       an unsolicited EXPUNGE response is sent.  The message number for
  927.       each successive message in the mailbox is immediately decremented
  928.       by 1; this means that if the last 5 messages in a 9-message mail
  929.       file are expunged the client will receive 5 unsolicited EXPUNGE
  930.       responses for message 5.
  931.  
  932.  
  933.    tag COPY sequence mailbox
  934.  
  935.       The COPY command copies the specified message(s) to the specified
  936.       destination mailbox.  The flags of the message(s) SHOULD be
  937.       preserved in the copy.
  938.  
  939.       If the destination mailbox does not exist, a server SHOULD return
  940.       an error.  It SHOULD NOT automatically create the mailbox.  Unless
  941.       it is certain that the destination mailbox can not be created, the
  942.       server MUST send the special information token "[TRYCREATE]" as
  943.       the prefix of the text of the tagged NO response.  This gives a
  944.       hint to the client that it can attempt a CREATE command and retry
  945.       the COPY if the CREATE is successful.
  946.  
  947.  
  948.  
  949. Crispin                                                        [Page 17]
  950.  
  951. Internet Draft                  IMAP2bis                October 27, 1993
  952.  
  953.  
  954.       If the COPY command is unsuccessful for any reason, IMAP2bis
  955.       server implementations MUST restore the destination mailbox its
  956.       prior state before the COPY attempt.
  957.  
  958.       EXAMPLE:  A003 COPY 2:4 MEETING
  959.       copies messages 2, 3, and 4 to mailbox "MEETING".
  960.  
  961.  
  962.    tag APPEND mailbox 0#flag literal
  963.  
  964.       The APPEND command appends the literal argument as a new message
  965.       in the specified destination mailbox.  This argument is in the
  966.       format of an RFC 822 message.  If any flags are specified, those
  967.       flags SHOULD be set in the resulting message.  If the append is
  968.       unsuccessful for any reason the mailbox must be restored to its
  969.       prior state before the APPEND attempt; no partial appending is
  970.       permitted.  If the mailbox is currently selected, the normal new
  971.       mail actions should occur.
  972.  
  973.       Server implementations SHOULD return a NO response if the length
  974.       of the literal is zero.
  975.  
  976.       If the destination mailbox does not exist, a server MUST return an
  977.       error, and MUST NOT automatically create the mailbox.  Unless it
  978.       is certain that the destination mailbox can not be created, the
  979.       server MUST send the special information token "[TRYCREATE]" as
  980.       the prefix of the text of the tagged NO response.  This gives a
  981.       hint to the client that it can attempt a CREATE command and retry
  982.       the APPEND if the CREATE is successful.
  983.  
  984.       Note that this functionality is unsuitable for message delivery,
  985.       because it does not provide a mechanism to transfer RFC 821 (SMTP)
  986.       envelope information.
  987.  
  988.  
  989.    tag FETCH sequence data
  990.  
  991.       The FETCH command retrieves data associated with a message in the
  992.       mailbox.  The data items to be fetched may be either a single atom
  993.       or an S-expression list.  The currently defined data items that
  994.       can be fetched are:
  995.  
  996.       ALL             Macro equivalent to:
  997.                       (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE)
  998.  
  999.       BODY            Non-extensible form of BODYSTRUCTURE.
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005. Crispin                                                        [Page 18]
  1006.  
  1007. Internet Draft                  IMAP2bis                October 27, 1993
  1008.  
  1009.  
  1010.       BODY[section]   The text of a particular body section.  The
  1011.                       section specification is a set of one or more
  1012.                       part numbers delimited by periods.
  1013.  
  1014.                       Single-part messages only have a part 1.
  1015.  
  1016.                       Multipart messages are assigned consecutive
  1017.                       part numbers, as they occur in the message.
  1018.                       If a particular part is of type message or multipart,
  1019.                       its parts must be indicated by a period followed by
  1020.                       the part number within that nested multipart part.
  1021.                       It is not permitted to fetch a multipart part
  1022.                       itself, only its individual members.
  1023.  
  1024.                       A part of type MESSAGE and subtype RFC822 also
  1025.                       has nested parts.  These are the parts of the
  1026.                       MESSAGE part's body.  Nested part 0 of a part of
  1027.                       type MESSAGE and subtype RFC822 is the RFC 822
  1028.                       header of the message.
  1029.  
  1030.                       Every message has at least one part.
  1031.  
  1032.                       EXAMPLE: Here is a complex message with its
  1033.                       associated section specifications.
  1034.                            1   TEXT/PLAIN
  1035.                            2   APPLICATION/OCTET-STREAM
  1036.                            3   MESSAGE/RFC822
  1037.                            3.0   (RFC 822 header of the message)
  1038.                            3.1   TEXT/PLAIN
  1039.                            3.2   APPLICATION/OCTET-STREAM
  1040.                                MULTIPART/MIXED
  1041.                            4.1   IMAGE/GIF
  1042.                            4.2   MESSAGE/RFC822
  1043.                            4.2.0   (RFC 822 header of the message)
  1044.                            4.2.1   TEXT/PLAIN
  1045.                                    MULTIPART/ALTERNATIVE
  1046.                            4.2.2.1  TEXT/PLAIN
  1047.                            4.2.2.2  TEXT/RICHTEXT
  1048.                       Note that there is no section specification for
  1049.                       the Multi-part parts (no section 4 or 4.2.2).
  1050.  
  1051.                       The \Seen flag is implicitly set; if this causes
  1052.                       the flags to change they should be included as
  1053.                       part of the fetch results.
  1054.  
  1055.       BODYSTRUCTURE   The MIME body structure of the message.  This
  1056.                       is computed by the server by parsing the MIME
  1057.                       header lines.
  1058.  
  1059.  
  1060.  
  1061. Crispin                                                        [Page 19]
  1062.  
  1063. Internet Draft                  IMAP2bis                October 27, 1993
  1064.  
  1065.  
  1066.       ENVELOPE        The envelope structure of the message.  This
  1067.                       computed by the server by parsing the RFC 822
  1068.                       header into the component parts, defaulting
  1069.                       various fields as necessary.
  1070.  
  1071.       FAST            Macro equivalent to:
  1072.                       (FLAGS INTERNALDATE RFC822.SIZE)
  1073.  
  1074.       FLAGS           The flags that are set for this message.
  1075.  
  1076.       FULL            Macro equivalent to:
  1077.                       (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODY)
  1078.  
  1079.       INTERNALDATE    The date and time the message was written to
  1080.                       the mailbox.
  1081.  
  1082.       RFC822          The message in RFC 822 format.  The \Seen
  1083.                       flag is implicitly set; if this causes the
  1084.                       flags to change they should be included as
  1085.                       part of the fetch results.  This is the
  1086.                       concatenation of RFC822.HEADER and RFC822.TEXT.
  1087.  
  1088.       RFC822.HEADER   The RFC 822 format header of the message as
  1089.                       stored on the server including the delimiting
  1090.                       blank line between the header and the body.
  1091.  
  1092.       RFC822.HEADER.LINES header_line_list
  1093.                       All header lines (including continuation lines)
  1094.                       of the RFC 822 format header of the message
  1095.                       with a field-name (as defined in RFC 822) that
  1096.                       matches any of the strings in header_line_list.
  1097.                       The matching is case-independent but otherwise
  1098.                       exact.
  1099.  
  1100.       RFC822.HEADER.LINES.NOT header_line_list
  1101.                       All header lines (including continuation lines)
  1102.                       of the RFC 822 format header of the message
  1103.                       with a field-name (as defined in RFC 822) that
  1104.                       does not match any of the strings in
  1105.                       header_line_list.  The matching is
  1106.                       case-independent but otherwise exact.
  1107.  
  1108.       RFC822.SIZE     The number of characters in the message as
  1109.                       expressed in RFC 822 format.
  1110.  
  1111.       RFC822.TEXT     The text body of the message, omitting the
  1112.                       RFC 822 header.  The \Seen flag is implicitly
  1113.                       set; if this causes the flags to change they
  1114.  
  1115.  
  1116.  
  1117. Crispin                                                        [Page 20]
  1118.  
  1119. Internet Draft                  IMAP2bis                October 27, 1993
  1120.  
  1121.  
  1122.                       should be included as part of the fetch results.
  1123.  
  1124.       UID             The unique identifier for the message.
  1125.  
  1126.       EXAMPLES:
  1127.  
  1128.       A003 FETCH 2:4 ALL
  1129.          fetches the flags, internal date, RFC 822 size, and envelope
  1130.          structure for messages 2, 3, and 4.
  1131.  
  1132.       A004 FETCH 3 RFC822
  1133.          fetches the RFC 822 representation for message 3.
  1134.  
  1135.       A005 FETCH 4 (FLAGS RFC822.HEADER)
  1136.          fetches the flags and RFC 822 format header for message 4.
  1137.  
  1138.  
  1139.    tag PARTIAL msgno data start_octet octet_count
  1140.  
  1141.       The PARTIAL command is equivalent to the associated FETCH command,
  1142.       with the added functionality that only the specified number of
  1143.       octets, beginning at the specified starting octet, are returned.
  1144.       Note that only a single message can be fetched at a time.  The
  1145.       first octet of a message, and hence the minimum for the starting
  1146.       octet, is octet 1.
  1147.  
  1148.       The following FETCH items are valid data for PARTIAL: RFC822,
  1149.       RFC822.HEADER, RFC822.TEXT, and BODY[section].
  1150.  
  1151.       Any partial fetch that attempts to read beyond the end of the text
  1152.       is truncated as appropriate.  If the starting octet is beyond the
  1153.       end of the text, an empty string is returned.
  1154.  
  1155.       The data are returned with the FETCH response.  There is no
  1156.       indication of the range of the partial data in this response; thus
  1157.       it is generally not possible to implement caching with PARTIAL
  1158.       data.  It is also not possible to stream multiple PARTIAL commands
  1159.       of the same data item without processing and synchronizing at each
  1160.       step, since each PARTIAL fetch of data replaces any prior
  1161.       (PARTIAL) FETCH of the data.
  1162.  
  1163.       Note that when partial fetching it is possible to break in the
  1164.       middle of a line or a critical sequence such as a BASE64 quadruple
  1165.       or QUOTED-PRINTABLE shift.  Implementations using partial fetching
  1166.       should keep this in mind.  There is no requirement that partial
  1167.       fetches follow any sequence; so if it turns out that a partial
  1168.       fetch of octets 1 through 10000 breaks in an awkward place, it is
  1169.       permitted to continue with a partial fetch of 9987 through 19987,
  1170.  
  1171.  
  1172.  
  1173. Crispin                                                        [Page 21]
  1174.  
  1175. Internet Draft                  IMAP2bis                October 27, 1993
  1176.  
  1177.  
  1178.       etc.
  1179.  
  1180.       The handling of the \Seen flag is the same as with the FETCH
  1181.       command.
  1182.  
  1183.  
  1184.    tag STORE sequence data value
  1185.  
  1186.       The STORE command alters data associated with a message in the
  1187.       mailbox.  The currently defined data items that can be stored are:
  1188.  
  1189.          FLAGS           Replace the flags for the message with the
  1190.                          argument (in flag list format).
  1191.  
  1192.          +FLAGS          Add the flags in the argument to the
  1193.                          message's flag list.
  1194.  
  1195.          -FLAGS          Remove the flags in the argument from the
  1196.                          message's flag list.
  1197.  
  1198.       EXAMPLE:  A003 STORE 2:4 +FLAGS (\Deleted)
  1199.       marks messages 2, 3, and 4 for deletion.
  1200.  
  1201.  
  1202.    UID commands
  1203.  
  1204.    These commands use unique identifiers instead of message numbers in
  1205.    their arguments to reference a particular message or range of
  1206.    messages.  The unique identifier of a message is guaranteed not to
  1207.    refer to any other message in the mailbox.  Unlike IMAP2bis sequence
  1208.    numbers, unique identifiers persist across sessions.
  1209.  
  1210.    Sequence ranges are permitted; note however that there is no
  1211.    guarantee that unique identifiers be contiguous.  A non-existent
  1212.    unique identifier within a sequence range is ignored without any
  1213.    error message generated.
  1214.  
  1215.    Because of the potential for ambiguity, the UID command does not
  1216.    change responses.  That is, the number after the "*" in an
  1217.    unsolicited FETCH response is a message number, not a unique
  1218.    identifier.  However, servers MUST implicitly include UID as part of
  1219.    any FETCH response caused by a UID command, regardless of whether UID
  1220.    was specified.
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229. Crispin                                                        [Page 22]
  1230.  
  1231. Internet Draft                  IMAP2bis                October 27, 1993
  1232.  
  1233.  
  1234.    EXAMPLE:  C: A003 UID FETCH 4827313:4828442 FLAGS
  1235.              S: * 23 FETCH (FLAGS (\Seen) UID 4827313)
  1236.              S: * 24 FETCH (FLAGS (\Seen) UID 4827943)
  1237.              S: * 25 FETCH (FLAGS (\Seen) UID 4828442)
  1238.              S: A003 UID FETCH completed
  1239.  
  1240.  
  1241.       tag UID AFTER uniqueid
  1242.  
  1243.          The UID AFTER command determines what unique identifiers exist
  1244.          that are greater than the specified unique identifier.  It
  1245.          returns unsolicited FETCH responses for each such message.
  1246.  
  1247.          For example, if the specified unique identifier refers to
  1248.          message 572 in a mailbox with 613 messages, the results
  1249.          returned are equivalent to doing "FETCH 573:613 UID".
  1250.  
  1251.  
  1252.       tag UID COPY sequence mailbox
  1253.  
  1254.          The UID COPY command is identical to the COPY command, with the
  1255.          exception that the numbers used in the sequence are unique
  1256.          identifiers instead of message numbers.
  1257.  
  1258.  
  1259.       tag UID FETCH sequence data
  1260.  
  1261.          The UID FETCH command is identical to the FETCH command, with
  1262.          the exception that the numbers used in the sequence are unique
  1263.          identifiers instead of message numbers.
  1264.  
  1265.  
  1266.       tag UID STORE sequence data value
  1267.  
  1268.          The UID STORE command is identical to the STORE command, with
  1269.          the exception that the numbers used in the sequence are unique
  1270.          identifiers instead of message numbers.
  1271.  
  1272.  
  1273.    tag SEARCH search_criteria
  1274.  
  1275.       The SEARCH command searches the mailbox for messages that match
  1276.       the given set of criteria.  The unsolicited SEARCH <1#number>
  1277.       response from the server is a list of messages that express the
  1278.       intersection (AND function) of all the messages that match that
  1279.       criteria.  For example,
  1280.               A003 SEARCH DELETED FROM "SMITH" SINCE 1-OCT-87
  1281.       returns the message numbers for all deleted messages from Smith
  1282.  
  1283.  
  1284.  
  1285. Crispin                                                        [Page 23]
  1286.  
  1287. Internet Draft                  IMAP2bis                October 27, 1993
  1288.  
  1289.  
  1290.       that were placed in the mail file since October 1, 1987.
  1291.  
  1292.       In all search criteria that use strings, a message matches the
  1293.       criteria if the string is a substring of the field.  The matching
  1294.       is case-independent except as noted below.
  1295.  
  1296.       The server may interpret an RFC 1522 format string to express text
  1297.       in a character set other than US-ASCII.  The criteria matches if
  1298.       the RFC 1522 interpreted string matches an interpreted substring
  1299.       (MIME or RFC 1522 as appropriate) of the field.
  1300.  
  1301.       A server implementation may omit case-independent matching on RFC
  1302.       1522 strings.
  1303.  
  1304.       The currently defined search criteria are:
  1305.  
  1306.       ALL             All messages in the mailbox; the default
  1307.                       initial criterion for ANDing.
  1308.  
  1309.       ANSWERED        Messages with the \Answered flag set.
  1310.  
  1311.       BCC istring     Messages that contain the specified string
  1312.                       in the envelope structure's BCC field.
  1313.  
  1314.       BEFORE date     Messages whose internal date is earlier than
  1315.                       the specified date.
  1316.  
  1317.       BODY istring    Messages that contain the specified string
  1318.                       in the body of the message.
  1319.  
  1320.       CC istring      Messages that contain the specified string
  1321.                       in the envelope structure's CC field.
  1322.  
  1323.       DELETED         Messages with the \Deleted flag set.
  1324.  
  1325.       FLAGGED         Messages with the \Flagged flag set.
  1326.  
  1327.       FROM istring    Messages that contain the specified string
  1328.                       in the envelope structure's FROM field.
  1329.  
  1330.       KEYWORD flag    Messages with the specified flag set.
  1331.  
  1332.       NEW             Messages that have the \Recent flag set but
  1333.                       not the \Seen flag.  This is functionally
  1334.                       equivalent to "RECENT UNSEEN".
  1335.  
  1336.       OLD             Messages that do not have the \Recent flag
  1337.                       set.
  1338.  
  1339.  
  1340.  
  1341. Crispin                                                        [Page 24]
  1342.  
  1343. Internet Draft                  IMAP2bis                October 27, 1993
  1344.  
  1345.  
  1346.       ON date         Messages whose internal date is within the
  1347.                       specified date.
  1348.  
  1349.       RECENT          Messages that have the \Recent flag set.
  1350.  
  1351.       SEEN            Messages that have the \Seen flag set.
  1352.  
  1353.       SINCE date      Messages whose internal date is later than
  1354.                       the specified date.
  1355.  
  1356.       SUBJECT istring Messages that contain the specified string
  1357.                       in the envelope structure's SUBJECT field.
  1358.  
  1359.       TEXT istring    Messages that contain the specified string.
  1360.  
  1361.       TO istring      Messages that contain the specified string in
  1362.                       the envelope structure's TO field.
  1363.  
  1364.       UIDAFTER uniqueid
  1365.                       Messages that have a UID greater than the
  1366.                       specified UID.
  1367.  
  1368.       UIDBEFORE uniqueid
  1369.                       Messages that have a UID less than the
  1370.                       specified UID.
  1371.  
  1372.       UNANSWERED      Messages that do not have the \Answered flag
  1373.                       set.
  1374.  
  1375.       UNDELETED       Messages that do not have the \Deleted flag
  1376.                       set.
  1377.  
  1378.       UNFLAGGED       Messages that do not have the \Flagged flag
  1379.                       set.
  1380.  
  1381.       UNKEYWORD flag  Messages that do not have the specified flag
  1382.                       set.
  1383.  
  1384.       UNSEEN          Messages that do not have the \Seen flag set.
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397. Crispin                                                        [Page 25]
  1398.  
  1399. Internet Draft                  IMAP2bis                October 27, 1993
  1400.  
  1401.  
  1402. Responses
  1403.  
  1404.    The first group of responses complete a request, and indicate whether
  1405.    the command was successful.  The response text is a line of human
  1406.    readable text, optionally prefixed by an atom inside square brackets
  1407.    that conveys a special information token between cooperating servers
  1408.    and clients.
  1409.  
  1410.    The currently defined special information tokens are:
  1411.  
  1412.       PARSE           An error occurred in parsing the RFC 822 or MIME
  1413.                       headers of a message in the mailbox.
  1414.  
  1415.       READ-ONLY       The mailbox is open read-only, or its access while
  1416.                       open has changed from read-write to read-only.
  1417.  
  1418.       READ-WRITE      The mailbox is open read-write, or its access while
  1419.                       open has changed from read-only to read-write.
  1420.  
  1421.       TRYCREATE       An APPEND or COPY attempt failed because the target
  1422.                       mailbox does not exist.  The server sends this as a
  1423.                       hint to the client that the operation would probably
  1424.                       succeed if the mailbox is first created by means of
  1425.                       the CREATE command.
  1426.  
  1427.       UNSEEN          Followed by a decimal number, indicates the number
  1428.                       of the first unread message.  This is intended to be
  1429.                       used with certain bboard formats to assist the user
  1430.                       in finding the first unread message in those cases
  1431.                       where "unread" and "recent" are separate concepts.
  1432.  
  1433.       hex string      A hexadecimal string is returned as a special
  1434.                       information token to represent a Kerberos return
  1435.                       authenticator.  This only occurs in response to a
  1436.                       LOGIN command that uses Kerberos authentication.
  1437.  
  1438.    Other special information tokens defined by particular client or
  1439.    server implementations should be prefixed with an "X" until they are
  1440.    added to a revision of this protocol.
  1441.  
  1442.  
  1443.    tag OK resp_text
  1444.  
  1445.       This response identifies successful completion of the command with
  1446.       that tag.  The response text may be useful in a protocol telemetry
  1447.       log for debugging purposes.
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453. Crispin                                                        [Page 26]
  1454.  
  1455. Internet Draft                  IMAP2bis                October 27, 1993
  1456.  
  1457.  
  1458.    tag NO resp_text
  1459.  
  1460.       This response identifies unsuccessful completion of the command
  1461.       with that tag.  The text is a line of human-readable text that
  1462.       probably should be displayed to the user in an error report by the
  1463.       client.
  1464.  
  1465.  
  1466.    tag BAD resp_text
  1467.  
  1468.       This response identifies faulty protocol received from the client;
  1469.       The text is a line of human-readable text that should be recorded
  1470.       in any telemetry as part of a bug report to the maintainer of the
  1471.       client.
  1472.  
  1473.  
  1474.    The second group of responses convey human-readable information.  The
  1475.    response text is a line of human readable text, optionally prefixed
  1476.    by an atom inside square brackets that conveys special information
  1477.    between cooperating servers and clients.
  1478.  
  1479.  
  1480.    * PREAUTH resp_text
  1481.  
  1482.       This response is one of three possible greetings at session
  1483.       startup.  It indicates that the session has already been
  1484.       authenticated by external means and thus no LOGIN command is
  1485.       needed.
  1486.  
  1487.  
  1488.    * OK resp_text
  1489.  
  1490.       This response identifies an information message from the server.
  1491.       It does not indicate completion of any particular request, nor is
  1492.       it necessarily related to any request.  The text is a line of
  1493.       human-readable text that should be presented to the user as an
  1494.       information message.
  1495.  
  1496.       This response is also one of three possible greetings at session
  1497.       startup.  It indicates that the session is not yet authenticated
  1498.       and that a LOGIN command is needed.
  1499.  
  1500.  
  1501.    * NO resp_text
  1502.  
  1503.       This response identifies a warning message from the server.  It
  1504.       does not indicate completion of any request, nor is it necessarily
  1505.       related to any request.  The text is a line of human-readable text
  1506.  
  1507.  
  1508.  
  1509. Crispin                                                        [Page 27]
  1510.  
  1511. Internet Draft                  IMAP2bis                October 27, 1993
  1512.  
  1513.  
  1514.       that should be presented to the user as a warning of improper
  1515.       operation.
  1516.  
  1517.  
  1518.    * BAD resp_text
  1519.  
  1520.       This response identifies a serious error message from the server.
  1521.       It does not indicate completion of any request, nor is it
  1522.       necessarily related to any request.  It may also indicate a faulty
  1523.       command from the client in which a tag could not be parsed.  The
  1524.       text is a line of human-readable text that should be presented to
  1525.       the user as a serious or possibly fatal error.
  1526.  
  1527.  
  1528.    * BYE text
  1529.  
  1530.       This response identifies that the server is about to close the
  1531.       connection.  The text is a line of human-readable text that should
  1532.       be displayed to the user in a status report by the client.  This
  1533.       may be sent as part of a normal logout sequence, or as a panic
  1534.       shutdown announcement by the server.  It is also used by some
  1535.       servers as an announcement of an inactivity autologout.
  1536.  
  1537.       This response is also one of three possible greetings at session
  1538.       startup.  It indicates that the server is not willing to accept a
  1539.       session from this client.
  1540.  
  1541.  
  1542.    The third group of responses convey data about the mailbox or
  1543.    messages inside the mailbox.  This is how message data are
  1544.    transmitted from the server to the client.
  1545.  
  1546.  
  1547.    * MAILBOX mstring
  1548.  
  1549.       This response occurs as a result of a FIND command for MAILBOXES
  1550.       and ALL.MAILBOXES.  The string is a mailbox name that matches the
  1551.       pattern in the command.
  1552.  
  1553.  
  1554.    * BBOARD mstring
  1555.  
  1556.       This response occurs as a result of a FIND command for BBOARDS and
  1557.       ALL.BBOARDS.  The string is a bulletin board name that matches the
  1558.       pattern in the command.
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565. Crispin                                                        [Page 28]
  1566.  
  1567. Internet Draft                  IMAP2bis                October 27, 1993
  1568.  
  1569.  
  1570.    * SEARCH number(s)
  1571.  
  1572.       This response occurs as a result of a SEARCH command.  The
  1573.       number(s) refer to those messages that match the search criteria.
  1574.       Each number is delimited by a space, e.g., "SEARCH 2 3 6".
  1575.  
  1576.  
  1577.    * FLAGS flag_list
  1578.  
  1579.       This response generally occurs as a result of a selection command
  1580.       (SELECT, BBOARD, and EXAMINE).  The flag list are the list of
  1581.       flags (at a minimum, the system-defined flags) that are applicable
  1582.       for this mailbox.  Flags other than the system flags are a
  1583.       function of the server implementation.
  1584.  
  1585.  
  1586.    * number message_data
  1587.  
  1588.       This response occurs as a result of any command when a mailbox is
  1589.       selected.  The message_data is one of the following:
  1590.  
  1591.  
  1592.       EXISTS  The number of messages in the mailbox.
  1593.  
  1594.  
  1595.       RECENT  The number of messages that have arrived since the
  1596.               previous time this mailbox was read.
  1597.  
  1598.  
  1599.       EXPUNGE The specified message number has been permanently
  1600.               removed from the mailbox, and the next message in the
  1601.               mailbox (if any) becomes that message number.
  1602.  
  1603.               An unsolicited EXPUNGE response MUST NOT be sent except
  1604.               while responding to a request other than FETCH, STORE,
  1605.               or SEARCH.  All references to message numbers sent after
  1606.               an unsolicited EXPUNGE response are adjusted to reflect
  1607.               the effect of the expunge.
  1608.  
  1609.                  Discussion: a potential ambiguity exists with
  1610.                  the FETCH, STORE, and SEARCH requests if the
  1611.                  server is permitted to send unsolicited EXPUNGE
  1612.                  responses.  This is because these requests can be
  1613.                  streamed.  If two successive FETCH requests are
  1614.                  streamed, and if during the time of the processing
  1615.                  of the first request there is an expunge response,
  1616.                  then the sequence of the second request is no
  1617.                  longer valid.
  1618.  
  1619.  
  1620.  
  1621. Crispin                                                        [Page 29]
  1622.  
  1623. Internet Draft                  IMAP2bis                October 27, 1993
  1624.  
  1625.  
  1626.       FETCH data
  1627.               This is the principal means that data about a message
  1628.               are returned to the client.  The data are in an
  1629.               S-expression form, and consists of a sequence of pairs
  1630.               of data item name and their values.  The current data
  1631.               items are:
  1632.  
  1633.          BODY          Similar to BODYSTRUCTURE, but without the extension
  1634.                        data.
  1635.  
  1636.          BODY[section] A string expressing the body contents of the
  1637.                        specified section.  The string should be
  1638.                        interpreted by the client according to the
  1639.                        content transfer encoding, body type, and subtype.
  1640.  
  1641.                        Note that non-textual data are transfer encoded;
  1642.                        therefore, the string is likely to be 7-bit
  1643.                        US-ASCII.  This is NOT necessarily the byte size
  1644.                        or character set of the interpreted result.
  1645.  
  1646.          BODYSTRUCTURE An S-expression format list that describes the body
  1647.                        structure of a message.  This is computed by the
  1648.                        server by parsing the RFC 822 header and body into
  1649.                        the component parts, defaulting various fields
  1650.                        as necessary.
  1651.  
  1652.                        Multiple parts are indicated by S-expression
  1653.                        nesting.  Instead of a body type as the first element
  1654.                        of the list there is a nested body.  The second
  1655.                        element of the list is the multipart subtype (mixed,
  1656.                        digest, parallel, alternative, etc.).
  1657.  
  1658.                        Extension data follows the multipart subtype.
  1659.                        Extension data is never returned with the older
  1660.                        BODY fetch, but may be returned with a BODYSTRUCTURE
  1661.                        fetch.  Extension data, if present, must be in the
  1662.                        defined order.
  1663.  
  1664.                        No multipart extension data is currently defined.
  1665.  
  1666.                        Any subsequent data is extension data, not yet defined
  1667.                        in this version of the protocol.  Such extension data
  1668.                        consist of zero or more NILs, strings, numbers,
  1669.                        and/or potentially nested lists of such data.  Clients
  1670.                        which do a BODYSTRUCTURE fetch MUST be prepared to
  1671.                        accept such extension data.  Servers MUST NOT send
  1672.                        such extension data until it has been defined by a
  1673.                        future version of the protocol.
  1674.  
  1675.  
  1676.  
  1677. Crispin                                                        [Page 30]
  1678.  
  1679. Internet Draft                  IMAP2bis                October 27, 1993
  1680.  
  1681.  
  1682.                        The basic fields of a non-multipart body part are in
  1683.                        the following order:
  1684.                          body type - a string giving the content type name
  1685.                            as defined in MIME
  1686.                          body subtype - a string giving the content subtype
  1687.                            name as defined in MIME
  1688.                          body parameter list - an S-expression list of
  1689.                            attribute/value pairs [e.g. (foo bar baz rag)
  1690.                            where "bar" is the value of "foo" and "rag" is
  1691.                            the value of "baz"] as defined in MIME.
  1692.                          body id - a string giving the content id as
  1693.                            defined in MIME.
  1694.                          body description - a string giving the content
  1695.                            description as defined in MIME.
  1696.                          body encoding - a string giving the content
  1697.                            transfer encoding as defined in MIME.
  1698.                          body size - a number giving the size of the
  1699.                            body in octets.  Note that this size is the
  1700.                            size in its transfer encoding and not the
  1701.                            resulting size after any decoding.
  1702.  
  1703.                        A body type of type MESSAGE and subtype RFC822
  1704.                        contains, immediately after the basic fields,
  1705.                        the envelope structure, body structure, and
  1706.                        size in text lines of the encapsulated message.
  1707.  
  1708.                        A body type of type TEXT contains, immediately
  1709.                        after the basic fields, the size of the body
  1710.                        in text lines.  Note that this size is the size
  1711.                        in its transfer encoding and not the resulting
  1712.                        size after any decoding.
  1713.  
  1714.                        Extension data follows the basic fields and the
  1715.                        type-specific fields listed above.  Extension data
  1716.                        is never returned with the older BODY fetch, but
  1717.                        may be returned with a BODYSTRUCTURE fetch.
  1718.                        Extension data, if present, must be in the defined
  1719.                        order.
  1720.  
  1721.                        The extension data of a non-multipart body part are
  1722.                        in the following order:
  1723.                          body MD5 - a string giving the content MD5 value
  1724.                            as defined in MIME
  1725.  
  1726.                        Any subsequent extension data are not yet defined
  1727.                        in this version of the protocol, and would be in the
  1728.                        form described above under multipart extension data.
  1729.  
  1730.  
  1731.  
  1732.  
  1733. Crispin                                                        [Page 31]
  1734.  
  1735. Internet Draft                  IMAP2bis                October 27, 1993
  1736.  
  1737.  
  1738.          ENVELOPE      An S-expression format list that describes the
  1739.                        envelope structure of a message.  This is computed
  1740.                        by the server by parsing the RFC 822 header into
  1741.                        the component parts, defaulting various fields
  1742.                        as necessary.
  1743.  
  1744.                        The fields of the envelope structure are in the
  1745.                        following order: date, subject, from, sender,
  1746.                        reply-to, to, cc, bcc, in-reply-to, and message-id.
  1747.                        The date, subject, in-reply-to, and message-id fields
  1748.                        are strings.  The from, sender, reply-to, to, cc,
  1749.                        and bcc fields are lists of address structures.
  1750.  
  1751.                        An address structure is an S-expression format list
  1752.                        that describes an electronic mail address.  The
  1753.                        fields of an address structure are in the following
  1754.                        order: personal name, source-route (a.k.a. the
  1755.                        at-domain-list in SMTP), mailbox name, and
  1756.                        host name.
  1757.  
  1758.                        RFC 822 group syntax is indicated by a special
  1759.                        form of address structure in which the host name
  1760.                        file is NIL.  If the mailbox name field is also NIL,
  1761.                        this is an end of group marker (semi-colon in RFC 822
  1762.                        syntax).  If the mailbox name field is non-NIL,
  1763.                        this is a start of group marker, and the mailbox
  1764.                        name field holds the group name phrase.
  1765.  
  1766.                        Any field of an envelope or address structure that
  1767.                        is not applicable is presented as the atom NIL.
  1768.                        Note that the server must default the reply-to
  1769.                        and sender fields from the from field; a client is
  1770.                        not expected to know to do this.
  1771.  
  1772.          FLAGS         An S-expression format list of flags that are set
  1773.                        for this message.  This may include the following
  1774.                        system flags:
  1775.  
  1776.                        \Seen         Message has been read
  1777.                        \Answered     Message has been answered
  1778.                        \Flagged      Message is "flagged" for
  1779.                                       urgent/special attention
  1780.                        \Deleted      Message is "deleted" for
  1781.                                       removal by later EXPUNGE
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789. Crispin                                                        [Page 32]
  1790.  
  1791. Internet Draft                  IMAP2bis                October 27, 1993
  1792.  
  1793.  
  1794.                        as well as the following special flag:
  1795.  
  1796.                        \Recent       Message arrived since the
  1797.                                       previous time this mailbox
  1798.                                       was read
  1799.  
  1800.          INTERNALDATE  A string containing the date and time the
  1801.                        message was written to the mailbox.
  1802.  
  1803.          RFC822        A string expressing the message in RFC 822
  1804.                        format.
  1805.  
  1806.          RFC822.HEADER A string expressing the RFC 822 format header
  1807.                        of the message, including the delimiting
  1808.                        blank line between the header and the body.
  1809.                        This is used for the FETCH data items
  1810.                        RFC822.HEADER, RFC822.HEADER.LINES, and
  1811.                        RFC822.HEADER.LINES.NOT (note that a blank
  1812.                        line is always included regardless of header
  1813.                        line restrictions).
  1814.  
  1815.          RFC822.SIZE   A number indicating the number of
  1816.                        characters in the message as expressed
  1817.                        in RFC 822 format.
  1818.  
  1819.          RFC822.TEXT   A string expressing the text body of the
  1820.                        message, omitting the RFC 822 header.
  1821.  
  1822.          UID           A number expressing the unique identifier
  1823.                        of the message.
  1824.  
  1825.  
  1826.       COPY    Obsolete.  New server implementations MUST NOT transmit
  1827.               this response.  Client implementations SHOULD ignore
  1828.               this response (not report an error).
  1829.  
  1830.  
  1831.       STORE data
  1832.               Obsolete and functionally equivalent to FETCH.  New
  1833.               server implementations MUST NOT transmit this response.
  1834.               Client implementations SHOULD treat this response as
  1835.               equivalent to the FETCH response.
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845. Crispin                                                        [Page 33]
  1846.  
  1847. Internet Draft                  IMAP2bis                October 27, 1993
  1848.  
  1849.  
  1850.    The final group of responses contains a single, special purpose
  1851.    response.
  1852.  
  1853.    + resp_text
  1854.  
  1855.       This response identifies that the server is ready to accept the
  1856.       text of a literal from the client.  The text of this response is a
  1857.       line of human-readable text of the server's choosing (it is
  1858.       generally never seen by a client's human user).
  1859.  
  1860.       The purpose of this command is to solve a synchronization problem
  1861.       that can occur if a string in a command is a literal.  This may
  1862.       occur when logging in (if the password contains "funny"
  1863.       characters), and always occurs when using the APPEND command,
  1864.       since a message consists of multiple lines.
  1865.  
  1866.       Normally, a command from the client is a single text line.  If the
  1867.       server detects an error in the command, it can simply discard the
  1868.       remainder of the line.  It cannot do this for commands that
  1869.       contain literals, since a literal can be an arbitrarily long
  1870.       amount of text, and the server may not even be expecting a
  1871.       literal.  This mechanism is provided so the client knows not to
  1872.       send a literal until the server expects it, preserving
  1873.       client/server synchronization.
  1874.  
  1875.       No such synchronization protection is provided for literals sent
  1876.       from the server to the client.  Any synchronization problems in
  1877.       this direction would be caused by a bug in the client or server.
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901. Crispin                                                        [Page 34]
  1902.  
  1903. Internet Draft                  IMAP2bis                October 27, 1993
  1904.  
  1905.  
  1906. Sample IMAP2bis session
  1907.  
  1908.    The following is a transcript of an IMAP2bis session.  A long line in
  1909.    this sample is broken for editorial clarity.
  1910.  
  1911.    S:   * OK IMAP2bis Service 7.2(62) at Thu, 29 Jul 1993 21:34:23 -0700 (PDT)
  1912.    C:   a001 login mrc secret
  1913.    S:   a001 OK LOGIN completed
  1914.    C:   a002 select inbox
  1915.    S:   * 18 EXISTS
  1916.    S:   * FLAGS (\Answered \Flagged \Deleted \Seen)
  1917.    S:   * 0 RECENT
  1918.    S:   a002 OK [READ-WRITE] SELECT completed
  1919.    S:   a003 fetch 12 full
  1920.    S:   * 12 FETCH (FLAGS (\Seen) INTERNALDATE "14-Jul-1993 02:44:25 -0700"
  1921.          RFC822.SIZE 4282 ENVELOPE ("Wed, 14 Jul 1993 02:23:25 -0700 (PDT)"
  1922.          "IMAP2bis WG mtg summary and minutes" (("Terry Gray" NIL "gray"
  1923.          "cac.washington.edu")) ((NIL NIL "owner-imap" "cac.washington.edu"))
  1924.          (("Terry Gray" NIL "gray" "cac.washington.edu")) ((NIL NIL "imap"
  1925.          "cac.washington.edu")) ((NIL NIL "minutes" "CNRI.Reston.VA.US")
  1926.          ("John C Klensin" NIL "KLENSIN" "INFOODS.MIT.EDU")("Erik Huizer"
  1927.          NIL "Erik.Huizer" "SURFnet.nl")) NIL NIL
  1928.          "<Pine.3.84.9307140123.B27397-0100000@shiva2.cac.washington.edu>")
  1929.           BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 92))
  1930.    S:    a003 OK FETCH completed
  1931.    C:    a004 fetch 12 rfc822.header
  1932.    S:    * 12 FETCH (RFC822.HEADER {485}
  1933.    S:    Date: Wed, 14 Jul 1993 02:23:25 -0700 (PDT)
  1934.    S:    From: Terry Gray <gray@cac.washington.edu>
  1935.    S:    Reply-To: Terry Gray <gray@cac.washington.edu>
  1936.    S:    Subject: IMAP2bis WG mtg summary and minutes
  1937.    S:    To: imap@cac.washington.edu
  1938.    S:    Cc: minutes@CNRI.Reston.VA.US,
  1939.    S:            John C Klensin <KLENSIN@INFOODS.MIT.EDU>,
  1940.    S:            Erik Huizer <Erik.Huizer@SURFnet.nl>
  1941.    S:    Message-Id:
  1942.    S:     <Pine.3.84.9307140123.B27397-0100000@shiva2.cac.washington.edu>
  1943.    S:    Mime-Version: 1.0
  1944.    S:    Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
  1945.    S:
  1946.    S:    )
  1947.    S:    a004 OK FETCH completed
  1948.    C:    a005 store 12 +flags \deleted
  1949.    S:    * 12 FETCH (FLAGS (\Seen \Deleted))
  1950.    S:    a005 OK +FLAGS completed
  1951.    C:    a006 logout
  1952.    S:    * BYE IMAP2bis server terminating connection
  1953.    S:    a006 OK LOGOUT completed
  1954.  
  1955.  
  1956.  
  1957. Crispin                                                        [Page 35]
  1958.  
  1959. Internet Draft                  IMAP2bis                October 27, 1993
  1960.  
  1961.  
  1962. Design Discussion
  1963.  
  1964.    IMAP2bis is a textual protocol.  The use of MIME encoding in IMAP2bis
  1965.    makes it possible to support 8-bit textual and binary mail.
  1966.  
  1967.    IMAP2bis implementations MAY transmit 8-bit or multi-octet characters
  1968.    in literals, but should do so only when the character set is
  1969.    identified.  For example, 8-bit characters are specifically permitted
  1970.    in MIME body parts (fetching BODY[section]) of type TEXT.  8-bit
  1971.    characters are also permitted in the argument to APPEND.
  1972.  
  1973.    Servers MUST NOT transmit 8-bit characters in RFC822.HEADER fetch
  1974.    results.  Servers MUST NOT transmit 8-bit characters in RFC822.TEXT
  1975.    (and by extension RFC822) fetch results, unless there are MIME data
  1976.    in the message that identify the character sets of all 8-bit data.
  1977.  
  1978.    Because 8-bit characters are permitted in the argument to APPEND, a
  1979.    server that is unable to preserve 8-bit data properly MUST be able to
  1980.    reversibly convert 8-bit APPEND data to 7-bit using MIME.
  1981.  
  1982.    Although a BINARY body encoding is defined, IMAP2bis does not permit
  1983.    unencoded binary strings.  A "binary string" is any string with NUL
  1984.    characters; a string with an excessive amount of CTL characters may
  1985.    also be considered to be binary.  The mixing of unencoded binary in
  1986.    the same stream as textual commands would make the protocol more
  1987.    vulnerable to synchronization problems.  Implementations MUST encode
  1988.    binary data into BASE64 before transmitting it with IMAP2bis.
  1989.  
  1990.    When operating in the online model, an IMAP2bis client should
  1991.    maintain a local cache of data from the mailbox.  This cache is an
  1992.    incomplete model of the mailbox, and at startup is generally empty.
  1993.    As the client processes all unsolicited data, it updates the cache
  1994.    based on this data.  When a tagged response arrives, the client's
  1995.    cache has been updated from the associated request.
  1996.  
  1997.    Note that a server can send data that the client did not request,
  1998.    such as mailbox size or flag updates.  A server MUST send mailbox
  1999.    size updates automatically while processing a command.  A server
  2000.    SHOULD send message flag updates automatically, without requiring the
  2001.    client to request such updates explicitly.
  2002.  
  2003.    Regardless of what implementation decisions a client may take on
  2004.    caching, a client MUST record EXISTS and RECENT updates and MUST NOT
  2005.    assume that a CHECK or NOOP command will return EXISTS or RECENT
  2006.    information.
  2007.  
  2008.    Although it is permitted for a server to send an unsolicited response
  2009.    while there is no command in progress, this practice SHOULD NOT be
  2010.  
  2011.  
  2012.  
  2013. Crispin                                                        [Page 36]
  2014.  
  2015. Internet Draft                  IMAP2bis                October 27, 1993
  2016.  
  2017.  
  2018.    followed because of flow control considerations.  It can cause an
  2019.    incautious implementation to deadlock.  A deadlock is avoided if
  2020.    either of the following conditions are true: (1) except for the
  2021.    greeting, the server never sends responses while there is no command
  2022.    in progress; (2) the server process is capable of reading commands
  2023.    while sending data.  The latter condition generally requires either a
  2024.    multi-threading server implementation or use of a polling facility
  2025.    and non-blocking I/O.
  2026.  
  2027.    If a server has an inactivity autologout timer, that timer MUST be of
  2028.    at least 30 minutes' duration.  The receipt of a NOOP command from
  2029.    the client during that interval should suffice to reset the
  2030.    autologout timer.  Periodic transmission of a NOOP from the client
  2031.    during periods of inactivity also has the benefit of avoiding the
  2032.    possible deadlock noted above.
  2033.  
  2034.    It is frequently asked why there is no message posting function in
  2035.    IMAP2bis.  Message posting is orthogonal to the scope of a mail
  2036.    access protocol and detracts from its primary focus.  SMTP (RFC 821)
  2037.    provides the minimal functionality needed for message posting without
  2038.    losing valuable capabilities (such as blind carbon copies).  Any
  2039.    message posting function in IMAP2bis would need, at a minimum, to
  2040.    provide equivalent functionality.
  2041.  
  2042.    At the time of the writing of this document, an extensive set of
  2043.    extensions to SMTP is in the Internet standards process.  Should
  2044.    those extensions become an Internet Standard it would be necessary to
  2045.    revise IMAP2bis again to provide corresponding capabilities, were a
  2046.    message posting facility to be included in IMAP2bis.  In other words,
  2047.    a duplication of effort would be required each time a change is made
  2048.    to message transport technology.
  2049.  
  2050.    Another undesirable aspect of message posting in IMAP2bis occurs when
  2051.    a remote server is used.  It is unlikely that a client would support
  2052.    multiple means of posting a message.  It adds excessive size and
  2053.    complexity that can not be afforded, particularly on smaller
  2054.    machines.  It also can lead to poor performance.  Consider a client
  2055.    connecting to an IMAP2bis server over an interactive satellite link
  2056.    to a foreign country.  A local message posting (SMTP) server is
  2057.    available that uses a lower-cost batched link.  Here, it would be
  2058.    wasteful to use the interactive link for posting.
  2059.  
  2060.    Message posting to IMAP2bis has been suggested as a means of
  2061.    authenticating postings.  The problem is that access authentication
  2062.    credentials are not necessarily the same as posting authentication
  2063.    credentials.  At some sites, the disclosure of a portion of access
  2064.    authentication credentials in a mail message (as a "From" or "Sender"
  2065.    address) may be a serious security breach of greater significance
  2066.  
  2067.  
  2068.  
  2069. Crispin                                                        [Page 37]
  2070.  
  2071. Internet Draft                  IMAP2bis                October 27, 1993
  2072.  
  2073.  
  2074.    than forged mail.
  2075.  
  2076.    The Internet message transport infrastructure has no concept of
  2077.    authentication credentials, and neither authentication syntax nor
  2078.    semantics are transferred within a message.  As a result, any attempt
  2079.    at authenticating a message via posting authentication is completely
  2080.    ineffective once the message leaves the authenticating server; any
  2081.    indication of authentication in the message can easily be reproduced
  2082.    further down the line.  Public-key based message authentication
  2083.    systems such as Privacy Enhanced Mail are now under development to
  2084.    address this problem.
  2085.  
  2086.    IMAP2bis does not address problems with multiple IMAP2bis servers at
  2087.    a single site, access control lists, and mobility of client
  2088.    configuration and address book information.  These and other issues
  2089.    are being considered for a companion protocol.
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125. Crispin                                                        [Page 38]
  2126.  
  2127. Internet Draft                  IMAP2bis                October 27, 1993
  2128.  
  2129.  
  2130. Formal Syntax
  2131.  
  2132.    The following syntax specification uses the augmented Backus-Naur
  2133.    Form (BNF) notation as specified in RFC 822 with one exception; the
  2134.    delimiter used with the "#" construct is a single space (SPACE) and
  2135.    not a comma.
  2136.  
  2137.    Except as noted otherwise, all alphabetic characters in the IMAP2bis
  2138.    protocol are case-insensitive.  For example, "LOGIN", "login" and
  2139.    "lOgIn" all refer to the same command, and \FLAGGED, \Flagged, and
  2140.    \FlAgGeD all refer to the same flag.  The use of upper or lower case
  2141.    characters to define token strings is for editorial clarity only,
  2142.    although they may be construed as defining a suggested usage.
  2143.    Implementations MUST accept these strings in a case-insensitive
  2144.    fashion.
  2145.  
  2146.    Syntax marked as obsolete may be encountered with implementations
  2147.    written for an older version of this specification.  New
  2148.    implementations SHOULD accept obsolete syntax as input, but MUST NOT
  2149.    otherwise use it.
  2150.  
  2151.    address         ::= "(" addr_name SPACE addr_adl SPACE addr_mailbox
  2152.                        SPACE addr_host ")"
  2153.  
  2154.    addr_adl        ::= nstring
  2155.  
  2156.    addr_host       ::= nstring
  2157.                        ;; NIL indicates RFC 822 group syntax
  2158.  
  2159.    addr_mailbox    ::= nstring
  2160.                        ;; NIL indicates end of RFC 822 group; if non-NIL
  2161.                        ;; and addr_host is NIL, holds RFC 822 group name
  2162.  
  2163.    addr_name       ::= nstring
  2164.  
  2165.    append          ::= "APPEND" SPACE mailbox [SPACE 1#flag] SPACE literal
  2166.  
  2167.    astring         ::= atom / string
  2168.  
  2169.    atom            ::= 1*<any CHAR except specials, SPACE, and CTLs>
  2170.  
  2171.    bboard          ::= "BBOARD" SPACE mailbox_bboard
  2172.  
  2173.    body            ::= "(" body_structure ")"
  2174.  
  2175.    body2           ::= "(" body2_structure ")"
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181. Crispin                                                        [Page 39]
  2182.  
  2183. Internet Draft                  IMAP2bis                October 27, 1993
  2184.  
  2185.  
  2186.    body2_extension ::= nstring / number / "(" 1#body2_extension ")"
  2187.                        ;; Future expansion.  Clients MUST accept body2
  2188.                        ;; extension fields.  Servers MUST NOT generate
  2189.                        ;; body2 extension fields.
  2190.  
  2191.    body2_md5       ::= nstring
  2192.                        ;; reserved for MD5 checksum
  2193.  
  2194.    body2_multipart ::= 1*body2 SPACE body_subtype [SPACE 1#body2_extension]
  2195.  
  2196.    body2_structure ::= body2_terminal / body2_multipart
  2197.  
  2198.    body2_terminal  ::= body_terminal SPACE body2_md5 [SPACE 1#body2_extension]
  2199.  
  2200.    body_basic      ::= body_type_basic SPACE body_subtype SPACE body_fields
  2201.  
  2202.    body_fields     ::= body_parameter SPACE body_id SPACE body_description
  2203.                        SPACE body_encoding SPACE body_size
  2204.  
  2205.    body_description
  2206.                    ::= nstring
  2207.  
  2208.    body_encoding   ::= <"> body_enc_def <"> / body_enc_other
  2209.  
  2210.    body_enc_def    ::= "7BIT" / "8BIT" / "BINARY" / "BASE64"/
  2211.                        "QUOTED-PRINTABLE"
  2212.  
  2213.    body_enc_other  ::= string
  2214.  
  2215.    body_id         ::= nstring
  2216.  
  2217.    body_msg        ::= body_msg_822 / body_msg_other
  2218.  
  2219.    body_msg_822    ::= body_type_msg SPACE body_subtyp_822 SPACE body_fields
  2220.                        SPACE envelope SPACE body SPACE body_size_lines
  2221.  
  2222.    body_msg_other  ::= body_type_msg SPACE body_subtype SPACE body_fields
  2223.                        ;; subtype MUST NOT be "RFC822"
  2224.  
  2225.    body_multipart  ::= 1*body SPACE body_subtype
  2226.  
  2227.    body_parameter  ::= nil / "(" 1#(string string) ")"
  2228.  
  2229.    body_section    ::= number / number "." body_section
  2230.  
  2231.    body_size       ::= number
  2232.                        ;; size in octets
  2233.  
  2234.  
  2235.  
  2236.  
  2237. Crispin                                                        [Page 40]
  2238.  
  2239. Internet Draft                  IMAP2bis                October 27, 1993
  2240.  
  2241.  
  2242.    body_size_lines ::= number
  2243.  
  2244.    body_structure  ::= body_terminal / body_multipart
  2245.  
  2246.    body_subtype    ::= string
  2247.  
  2248.    body_subtyp_822 ::= <"> "RFC822" <">
  2249.  
  2250.    body_terminal   ::= body_basic / body_msg / body_text
  2251.  
  2252.    body_text       ::= body_type_text SPACE body_subtype SPACE body_fields
  2253.                        SPACE body_size_lines
  2254.  
  2255.    body_type_basic ::= <"> ("APPLICATION" / "AUDIO" / "IMAGE" / "VIDEO") <"> /
  2256.                        string
  2257.  
  2258.    body_type_msg   ::= <"> "MESSAGE" <">
  2259.  
  2260.    body_type_text  ::= <"> "TEXT" <">
  2261.  
  2262.    CHAR            ::= <any 7-bit US-ASCII character except NUL, 0x01 - 0x7f>
  2263.  
  2264.    CHAR8           ::= <any 8-bit octet except NUL, 0x01 - 0xff>
  2265.  
  2266.    check           ::= "CHECK"
  2267.  
  2268.    copy            ::= "COPY" SPACE sequence SPACE mailbox
  2269.  
  2270.    CR              ::= <ASCII CR, carriage return, 0x0C>
  2271.  
  2272.    create          ::= create_real / create_check
  2273.  
  2274.    create_check    ::= "CREATE" SPACE "INBOX"
  2275.                        ;; returns a NO response (not BAD)
  2276.  
  2277.    create_real     ::= "CREATE" SPACE mailbox_other
  2278.  
  2279.    CRLF            ::= CR LF
  2280.  
  2281.    CTL             ::= <any ASCII control character and DEL, 0x00 - 0x1f,
  2282. 0x7f>
  2283.  
  2284.    date            ::= date_text / <"> date_text <">
  2285.  
  2286.    date_day        ::= 1*2DIGIT
  2287.                        ;; day of month
  2288.  
  2289.    date_day_fixed  ::= (SPACE 1DIGIT) / 2DIGIT
  2290.                        ;; fixed-format version of date_day
  2291.  
  2292.  
  2293.  
  2294. Crispin                                                        [Page 41]
  2295.  
  2296. Internet Draft                  IMAP2bis                October 27, 1993
  2297.  
  2298.  
  2299.    date_month      ::= "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
  2300.                        "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"
  2301.  
  2302.    date_text       ::= date_day "-" date_month "-" (date_year / date_year_old)
  2303.  
  2304.    date_year       ::= 4DIGIT
  2305.  
  2306.    date_year_old   ::= 2DIGIT
  2307.                        ;; Obsolete, (year - 1900)
  2308.  
  2309.    date_time       ::= <"> (date_time_new / date_time_old) <">
  2310.  
  2311.    date_time_new   ::= date_day_fixed "-" date_month "-" date_year SPACE
  2312.                        time SPACE zone
  2313.  
  2314.    date_time_old   ::= date_day_fixed "-" date_month "-" date_year_old SPACE
  2315.                        time "-" zone_old
  2316.                        ;; Obsolete
  2317.  
  2318.    delete          ::= "DELETE" SPACE mailbox_other
  2319.  
  2320.    DIGIT           ::= <any ASCII decimal digit, 0x30 - 0x39>
  2321.  
  2322.    DIGIT_HEX       :: DIGIT / "a" / "b" / "c" / "d" / "e" / "f"
  2323.  
  2324.    envelope        ::= "(" env_date SPACE env_subject SPACE env_from SPACE
  2325.                        env_sender SPACE env_reply-to SPACE env_to SPACE
  2326.                        env_cc SPACE env_bcc SPACE env_in-reply-to SPACE
  2327.                        env_message-id ")"
  2328.  
  2329.    env_bcc         ::= nil / "(" 1*address ")"
  2330.  
  2331.    env_cc          ::= nil / "(" 1*address ")"
  2332.  
  2333.    env_date        ::= nstring
  2334.  
  2335.    env_from        ::= nil / "(" 1*address ")"
  2336.  
  2337.    env_in-reply-to ::= nstring
  2338.  
  2339.    env_message-id  ::= nstring
  2340.  
  2341.    env_reply-to    ::= nil / "(" 1*address ")"
  2342.  
  2343.    env_sender      ::= nil / "(" 1*address ")"
  2344.  
  2345.    env_subject     ::= nstring
  2346.  
  2347.  
  2348.  
  2349.  
  2350. Crispin                                                        [Page 42]
  2351.  
  2352. Internet Draft                  IMAP2bis                October 27, 1993
  2353.  
  2354.  
  2355.    env_to          ::= nil / "(" 1*address ")"
  2356.  
  2357.    examine         ::= "EXAMINE" SPACE mailbox
  2358.  
  2359.    expunge         ::= "EXPUNGE"
  2360.  
  2361.    fetch           ::= "FETCH" SPACE sequence SPACE ("ALL" / "FULL" /
  2362.                        "FAST" / fetch_att / "(" 1#fetch_att ")")
  2363.  
  2364.    fetch_att       ::= fetch_att_lines / fetch_att_other / fetch_att_text
  2365.  
  2366.    fetch_att_lines ::= "RFC822.HEADER.LINES" SPACE header_line_list /
  2367.                        "RFC822.HEADER.LINES.NOT" SPACE header_line_list /
  2368.  
  2369.    fetch_att_other ::= "BODY" / "BODYSTRUCTURE" / "ENVELOPE" / "FLAGS" /
  2370.                        "INTERNALDATE" / "RFC822.SIZE" / "UID"
  2371.  
  2372.    fetch_att_text  ::= "BODY[" body_section "]" / "RFC822" /
  2373.                        "RFC822.HEADER" / "RFC822.TEXT"
  2374.  
  2375.    find            ::= find_mailbox / find_bboard
  2376.  
  2377.    find_bboard     ::= find_bboards / find_boards_all
  2378.  
  2379.    find_bboards    ::= "FIND" SPACE "BBOARDS" SPACE find_pattern
  2380.  
  2381.    find_bboards_all
  2382.                    ::= "FIND" SPACE "ALL.BBOARDS" SPACE find_pattern
  2383.  
  2384.    find_mailbox    ::= find_mailboxes / find_mailboxes_all
  2385.  
  2386.    find_mailboxes  ::= "FIND" SPACE "MAILBOXES" SPACE find_pattern
  2387.  
  2388.    find_mailboxes_all
  2389.                    ::= "FIND" SPACE "ALL.MAILBOXES" SPACE find_pattern
  2390.  
  2391.    find_pattern    ::= astring
  2392.                        ;; includes find_wildcards
  2393.  
  2394.    find_wildcards  ::= "%" / "?" / "*"
  2395.  
  2396.    flag            ::= user_flag / system_flag
  2397.  
  2398.    flag_list       ::= "(" 1#flag ")"
  2399.  
  2400.    flags           ::= 1#flag / flag_list
  2401.  
  2402.    greeting        ::= "*" SPACE (resp_cond_auth / resp_cond_bye) CRLF
  2403.  
  2404.  
  2405.  
  2406. Crispin                                                        [Page 43]
  2407.  
  2408. Internet Draft                  IMAP2bis                October 27, 1993
  2409.  
  2410.  
  2411.    header_line     ::= astring
  2412.  
  2413.    header_line_list
  2414.                    ::= "(" 1#header_line ")"
  2415.  
  2416.    inbox           ::= "INBOX"
  2417.                        ;; case-independent, but SHOULD be upper-case
  2418.  
  2419.    istring         ::= astring
  2420.                        ;; possible RFC 1522 format data
  2421.  
  2422.    kerberos_authenticator
  2423.                    ::= 1*DIGIT_HEX
  2424.  
  2425.    kerberos_response
  2426.                    ::= 1*DIGIT_HEX
  2427.  
  2428.    LF              ::= <ASCII LF, line feed, 0x0A>
  2429.  
  2430.    literal         ::= "{" number "}" CRLF 1*CHAR8
  2431.                        ;; The number represents the number of CHAR8 octets.
  2432.  
  2433.    login           ::= "LOGIN" SPACE userid SPACE password
  2434.  
  2435.    logout          ::= "LOGOUT"
  2436.  
  2437.    mailbox         ::= inbox / mailbox_other
  2438.  
  2439.    mailbox_bboard  ::= astring
  2440.                        ;; May not be INBOX (in any case).  Should not
  2441.                        ;; include find_wildcards.  May be case-dependent
  2442.                        ;; as a function of server implementation.  May
  2443.                        ;; be a different namespace from mailbox_other.
  2444.  
  2445.  
  2446.  
  2447.  
  2448.    mailbox_other   ::= astring
  2449.                        ;; May not be INBOX (in any case).  Should not
  2450.                        ;; include find_wildcards.  May be case-dependent
  2451.                        ;; as a function of server implementation
  2452.  
  2453.    mailbox_data    ::= "MAILBOX" SPACE mstring / "BBOARD" SPACE mstring /
  2454.                         "SEARCH" [SPACE 1#number] / "FLAGS" SPACE flag_list
  2455.  
  2456.    message_data    ::= number SPACE (msg_exists / msg_recent / msg_expunge /
  2457.                        msg_fetch / msg_obsolete)
  2458.  
  2459.  
  2460.  
  2461.  
  2462. Crispin                                                        [Page 44]
  2463.  
  2464. Internet Draft                  IMAP2bis                October 27, 1993
  2465.  
  2466.  
  2467.    msg_copy        ::= "COPY"
  2468.                        ;; Obsolete
  2469.  
  2470.    msg_exists      ::= "EXISTS"
  2471.  
  2472.    msg_expunge     ::= "EXPUNGE"
  2473.  
  2474.    msg_fetch       ::= "FETCH" SPACE "(" 1#("BODY" SPACE body /
  2475.                        "BODYSTRUCTURE" SPACE body2 /
  2476.                        "BODY[" body_section "]" nstring /
  2477.                        "ENVELOPE" SPACE envelope /
  2478.                        "FLAGS" SPACE "(" 0#(recent_flag / flag) ")" /
  2479.                        "INTERNALDATE" SPACE date_time /
  2480.                        "RFC822" SPACE nstring /
  2481.                        "RFC822.HEADER" SPACE nstring /
  2482.                        "RFC822.SIZE" SPACE number /
  2483.                        "RFC822.TEXT" SPACE nstring /
  2484.                        "UID" SPACE uniqueid) ")"
  2485.  
  2486.    msg_obsolete    ::= msg_copy / msg_store
  2487.                        ;; Obsolete unsolicited data responses
  2488.  
  2489.    msg_recent      ::= "RECENT"
  2490.  
  2491.    msg_store       ::= "STORE" SPACE "(" 1#("FLAGS" SPACE
  2492.                        "(" 0#(recent_flag / flag) "))"
  2493.                        ;; Obsolete
  2494.  
  2495.    mstring         ::= text_line
  2496.                        ;; Represents a mailbox
  2497.  
  2498.    nil             ::= "NIL"
  2499.  
  2500.    noop            ::= "NOOP"
  2501.  
  2502.    nstring         ::= nil / string
  2503.  
  2504.    number          ::= 1*DIGIT
  2505.  
  2506.    partial         ::= "PARTIAL" SPACE number SPACE fetch_att_text SPACE
  2507.                        number SPACE number
  2508.  
  2509.    password        ::= astring / "@KERBEROS:" kerberos_authenticator
  2510.  
  2511.    QCHAR           ::= <any CHAR except qspecials, CR, and LF>
  2512.  
  2513.    qspecials       ::= <"> / "%" / "\"
  2514.  
  2515.  
  2516.  
  2517.  
  2518. Crispin                                                        [Page 45]
  2519.  
  2520. Internet Draft                  IMAP2bis                October 27, 1993
  2521.  
  2522.  
  2523.    quoted_string   ::= <"> *QCHAR <">
  2524.  
  2525.    recent_flag     ::= "\Recent"
  2526.  
  2527.    ready           ::= "+" SPACE resp_text
  2528.  
  2529.    rename          ::= "RENAME" SPACE mailbox SPACE mailbox_other
  2530.  
  2531.    request         ::= tag SPACE (request_auth / request_authed /
  2532. request_open)
  2533.                        ;; modal based on state
  2534.  
  2535.    request_any     ::= noop / logout
  2536.                        ;; valid in all modes
  2537.  
  2538.    request_auth    ::= request_any / login
  2539.                        ;; valid only when in not authenticated mode
  2540.  
  2541.    request_authed  ::= request_any / create / delete / rename / find /
  2542.                        subscribe / unsubscribe / select / examine / bboard /
  2543.                        append / x_command
  2544.                        ;; valid only when in authenticated or mailbox open
  2545. mode
  2546.  
  2547.    request_open    ::= request_authed / check / expunge / copy / fetch /
  2548.                        partial / store / uid / search / x_command
  2549.                        ;; valid only when in mailbox open mode
  2550.  
  2551.    response        ::= *<response_data> response_done
  2552.  
  2553.    response_data   ::= "*" SPACE (resp_cond_state / resp_cond_bye /
  2554.                        mailbox_data / message_data) CRLF
  2555.  
  2556.    response_done   ::= response_tagged / response_fatal
  2557.  
  2558.    response_fatal  ::= "*" SPACE resp_cond_bye CRLF
  2559.  
  2560.    response_tagged ::= tag SPACE resp_cond_state CRLF
  2561.  
  2562.    resp_cond_auth  ::= ("OK" / "PREAUTH") SPACE resp_text
  2563.                        ;; authentication condition
  2564.  
  2565.    resp_cond_bye   ::= "BYE" SPACE resp_text
  2566.                        ;; server will disconnect condition
  2567.  
  2568.    resp_cond_state ::= ("OK" / "NO" / "BAD") SPACE resp_text
  2569.                        ;; status condition
  2570.  
  2571.    resp_text       ::= [resp_token SPACE] text_line
  2572.  
  2573.  
  2574.  
  2575.  
  2576. Crispin                                                        [Page 46]
  2577.  
  2578. Internet Draft                  IMAP2bis                October 27, 1993
  2579.  
  2580.  
  2581.    resp_token      ::= "[" resp_token_type "]" [SPACE res_token_arg]
  2582.  
  2583.    resp_token_arg  ::= 1#number
  2584.                        ;; arguments depend upon token type
  2585.  
  2586.    resp_token_type ::= "PARSE" / "READ-ONLY" / "READ-WRITE" / "TRYCREATE" /
  2587.                        "UNSEEN" / "X" atom / kerberos_response
  2588.  
  2589.    search          ::= "SEARCH" SPACE 1#("ALL" / "ANSWERED" /
  2590.                        "BCC" SPACE istring / "BEFORE" SPACE date /
  2591.                        "BODY" SPACE istring / "CC" SPACE istring / "DELETED" /
  2592.                        "FLAGGED" / "FROM" space istring /
  2593.                        "KEYWORD" SPACE user_flag / "NEW" / "OLD" /
  2594.                        "ON" SPACE date / "RECENT" / "SEEN" /
  2595.                        "SINCE" SPACE date / "SUBJECT" SPACE istring /
  2596.                        "TEXT" SPACE istring / "TO" SPACE istring /
  2597.                        "UIDBEFORE" SPACE uniqueid / "UIDAFTER" SPACE uniqueid
  2598. /
  2599.                        "UNANSWERED" / "UNDELETED" / "UNFLAGGED" /
  2600.                        "UNKEYWORD" SPACE user_flag / "UNSEEN")
  2601.  
  2602.    select          ::= "SELECT" SPACE mailbox
  2603.  
  2604.    sequence        ::= number / (sequence "," sequence) / (number ":" number)
  2605.                        ;; identifies a set of messages by consecutive numbers
  2606.                        ;; from 1 to the number of messages in the mailbox.
  2607.                        ;; Comma delimits individual numbers, colon delimits
  2608.                        ;; between two numbers inclusive.
  2609.                        ;; Example: 2,4:7,9,12:15 is 2,4,5,6,7,9,12,13,14,15
  2610.  
  2611.    SPACE           ::= <ASCII SP, space, 0x20>
  2612.  
  2613.    specials        ::= "(" / ")" / "{" / qspecials
  2614.  
  2615.    store           ::= "STORE" SPACE sequence SPACE store_att
  2616.  
  2617.    store_att       ::= "+FLAGS" SPACE flags / "-FLAGS" SPACE flags /
  2618.                        "FLAGS" SPACE flags
  2619.  
  2620.    string          ::= quoted_string / literal
  2621.  
  2622.    subscribe       ::= subscribe_mailbox / subscribe_bboard
  2623.  
  2624.    subscribe_bboard
  2625.                    ::= "SUBSCRIBE" SPACE "BBOARD" SPACE mailbox_bboard
  2626.  
  2627.    subscribe_mailbox
  2628.                    ::= "SUBSCRIBE" SPACE "MAILBOX" SPACE mailbox
  2629.  
  2630.  
  2631.  
  2632.  
  2633. Crispin                                                        [Page 47]
  2634.  
  2635. Internet Draft                  IMAP2bis                October 27, 1993
  2636.  
  2637.  
  2638.    system_flag     ::= "\Answered" / "\Flagged" / "\Deleted" / "\Seen" /
  2639.                        system_flag_new
  2640.  
  2641.    system_flag_new ::= "\" atom
  2642.                        ;; future expansion
  2643.  
  2644.    tag             ::= 1*<any CHAR except "*", "+", specials, SPACE, and CTLs>
  2645.  
  2646.    text_line       ::= 1*<any CHAR except CR and LF>
  2647.  
  2648.    time            ::= 2DIGIT ":" 2DIGIT ":" 2DIGIT
  2649.                        ;; hours minutes seconds
  2650.  
  2651.    uid             ::= "UID" SPACE (uid_after / copy / fetch / store)
  2652.                        ;; uniqueids used instead of message numbers
  2653.  
  2654.    uid_after       ::= "AFTER" SPACE uniqueid
  2655.  
  2656.    uniqueid        ::= number
  2657.                        ;;; strictly ascending
  2658.  
  2659.    unsubscribe     ::= unsubscribe_mailbox / unsubscribe_bboard
  2660.  
  2661.    unsubscribe_bboard
  2662.                    ::= "UNSUBSCRIBE" SPACE "BBOARD" SPACE mailbox_bboard
  2663.  
  2664.    unsubscribe_mailbox
  2665.                    ::= "UNSUBSCRIBE" SPACE "MAILBOX" SPACE mailbox_mailbox
  2666.  
  2667.    userid          ::= astring
  2668.  
  2669.    user_flag       ::= atom
  2670.  
  2671.    x_command       ::= "X" atom <optional arguments>
  2672.                        ;; experimental expansion commands
  2673.  
  2674.    zone            ::= ("+" / "-") 4DIGIT
  2675.                        ;; Signed four-digit value of hhmm representing
  2676.                        ;; hours and minutes west of Greenwich (that is,
  2677.                        ;; (the amount that the given time differs from
  2678.                        ;; Universal Time).  Subtracting the timezone
  2679.                        ;; from the given time will give the UT form.
  2680.                        ;; The Universal Time zone is "+0000".
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689. Crispin                                                        [Page 48]
  2690.  
  2691. Internet Draft                  IMAP2bis                October 27, 1993
  2692.  
  2693.  
  2694.    zone_old        ::= "UT" / "GMT" / "Z" /                ;; +0000
  2695.                        "AST" / "EST" / "CST" / "MST" /     ;; -0400 to -0700
  2696.                        "PST" / "YST" / "HST" / "BST" /     ;; -0800 to -1100
  2697.                        "ADT" / "EDT" / "CDT" / "MDT" /     ;; -0300 to -0600
  2698.                        "PDT" / "YDT" / "HDT" / "BDT" /     ;; -0700 to -1000
  2699.                        "A" / "B" / "C" / "D" / "E" / "F" / ;; +0100 to +0600
  2700.                        "G" / "H" / "I" / "K" / "L" / "M" / ;; +0700 to +1200
  2701.                        "N" / "O" / "P" / "Q" / "R" / "S" / ;; -0100 to -0600
  2702.                        "T" / "U" / "V" / "W" / "X" / "Y"   ;; -0700 to -1200
  2703.                        ;; Obsolete
  2704.  
  2705.    A protocol session is as follows:
  2706.  
  2707.     Server: greeting
  2708.     *<Client: request (first part, if it contains a literal)
  2709.       *<Server: ready
  2710.         Client: request (next part)
  2711.        >
  2712.       Server: response
  2713.      >
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745. Crispin                                                        [Page 49]
  2746.  
  2747. Internet Draft                  IMAP2bis                October 27, 1993
  2748.  
  2749.  
  2750. Compatibility Notes
  2751.  
  2752.    This is a summary of hints and recommendations to enable an IMAP2bis
  2753.    implementation, written to this specification, to interoperate with
  2754.    implementations that conform to earlier specifications.  None of
  2755.    these hints and recommendations are required by this specification;
  2756.    implementors must decide for themselves whether they want their
  2757.    implementation to fail if it encounters old software.
  2758.  
  2759.    IMAP2bis has been designed to be upwards compatible with earlier
  2760.    specifications.  IMAP2bis facilities that were not in earlier
  2761.    specifications should be invisible to clients unless the client asks
  2762.    for the facility.
  2763.  
  2764.    This information may not be complete; it reflects current knowledge
  2765.    of server and client implementations as well as "folklore" acquired
  2766.    in the evolution of the protocol.
  2767.  
  2768.       IMAP2bis client interoperability with old servers
  2769.  
  2770.       In general, a client should be able to discover whether a server
  2771.       supports a facility by trial-and-error; if an attempt to use a
  2772.       facility generates a BAD response, the client can assume that the
  2773.       server does not support the facility.
  2774.  
  2775.       Some servers may disable certain commands as a matter of
  2776.       intentional site policy.  For example, a bboard-only server may
  2777.       disable the SELECT command.  Such servers should return a NO
  2778.       response to disabled commands instead of a BAD response.
  2779.  
  2780.       A quick way to check whether a server implementation supports this
  2781.       specification is to try a UID FETCH 0 UID command.  An OK or NO
  2782.       response would indicate a server that conforms to this
  2783.       specification; a BAD response would indicate an older server.
  2784.  
  2785.          The CREATE, DELETE, and RENAME commands are new in IMAP2bis,
  2786.          and may not be present in old servers.  A safe mechanism to
  2787.          test whether these commands are present is to try a CREATE
  2788.          INBOX command.  If the response is NO, these commands are
  2789.          supported by the server.  If the response is BAD, they are not.
  2790.          If the response is OK, the server's implementation is broken,
  2791.          since creating INBOX is not permitted.
  2792.  
  2793.          The FIND MAILBOXES and FIND BBOARDS commands are new in RFC
  2794.          1176.  A BAD response to these commands indicates a server that
  2795.          does not support any form of FIND.  It also indicates a server
  2796.          that does not support SUBSCRIBE and UNSUBSCRIBE.  Note that the
  2797.          definition of the FIND MAILBOXES and FIND BBOARDS commands in
  2798.  
  2799.  
  2800.  
  2801. Crispin                                                        [Page 50]
  2802.  
  2803. Internet Draft                  IMAP2bis                October 27, 1993
  2804.  
  2805.  
  2806.          RFC 1176 differs from the definition in this specification; in
  2807.          RFC 1176 these commands were defined as returning a list of
  2808.          mailboxes or bulletin boards with no clear specification of
  2809.          whether the returned values were "subscribed" or "all possible"
  2810.          names.
  2811.  
  2812.          The FIND ALL.MAILBOXES and FIND ALL.BBOARDS commands are new in
  2813.          IMAP2bis.  A BAD response to these commands indicates a server
  2814.          that does not support a concept of subscriptions to a mailbox
  2815.          or bulletin board.  The server may support FIND MAILBOXES and
  2816.          FIND BBOARDS using the older RFC 1176 semantics.
  2817.  
  2818.          The SUBSCRIBE and UNSUBSCRIBE commands are new in IMAP2bis.  A
  2819.          server that supports FIND ALL.MAILBOXES and FIND ALL.BBOARDS
  2820.          will also support the SUBSCRIBE and UNSUBSCRIBE commands.
  2821.  
  2822.          The EXAMINE command is new in IMAP2bis.  A BAD response to this
  2823.          command indicates a server that does not support an explicit
  2824.          read-only mode of access, and a SELECT command should be used
  2825.          instead.
  2826.  
  2827.          Older server implementations may automatically create the
  2828.          destination mailbox on COPY if that mailbox does not already
  2829.          exist.  This was how a new mailbox was created in older
  2830.          specifications.  If the server does not support the CREATE
  2831.          command (see above for how to test for this), it will probably
  2832.          create a mailbox on COPY.
  2833.  
  2834.          The APPEND command is new in IMAP2bis.  A way to see if this
  2835.          command is implemented is to try to append a zero-length stream
  2836.          to a mailbox name that is known not to exist (or at least,
  2837.          highly unlikely to exist) on the remote system.
  2838.  
  2839.          Although IMAP2bis clients SHOULD avoid asking for the same data
  2840.          more than once (by having a client-based cache of data returned
  2841.          by the server), this is not a requirement of the protocol.
  2842.          However, IMAP2bis clients MUST cache data from the EXISTS and
  2843.          RECENT unsolicited responses.  Only the SELECT command is
  2844.          guaranteed to return EXISTS/RECENT information.
  2845.  
  2846.          The BODY, BODY[section], and FULL fetch data items are new in
  2847.          IMAP2bis.  A BAD response to an attempt to fetch either data
  2848.          item indicates a server that does not support server-based MIME
  2849.          parsing.
  2850.  
  2851.          The BODYSTRUCTURE fetch data item is new in IMAP2bis.  A BAD
  2852.          response to an attempt to fetch this data item indicates a
  2853.          server that does not support extensible results from server-
  2854.  
  2855.  
  2856.  
  2857. Crispin                                                        [Page 51]
  2858.  
  2859. Internet Draft                  IMAP2bis                October 27, 1993
  2860.  
  2861.  
  2862.          based MIME parsing.  The server may be running an earlier,
  2863.          experimental version of IMAP2bis and support the older, non-
  2864.          extensible, BODY fetch data item.  A client should attempt this
  2865.          data item before deciding that the server does not support
  2866.          MIME.
  2867.  
  2868.          The use of nested part 0 of a part of type MESSAGE in a BODY or
  2869.          BODYSTRUCTURE fetch to get only the RFC 822 header of the
  2870.          message is new, and is not in earlier, experimental versions of
  2871.          IMAP2bis.  A server that returns NIL is probably running the
  2872.          earlier version; with such servers the only way to obtain the
  2873.          RFC 822 header is to fetch the entire nested message.
  2874.  
  2875.          The RFC822.HEADER.LINES and RFC822.HEADER.LINES.NOT fetch data
  2876.          items are new in IMAP2bis.  A BAD response to an attempt to
  2877.          fetch this data item indicates a server that does not support
  2878.          selective header fetching.  A client should use RFC822.HEADER
  2879.          and remove the unwanted information.
  2880.  
  2881.          The UID fetch data item and the UID commands are new in
  2882.          IMAP2bis.  A BAD response to an attempt to use these indicates
  2883.          a server that does not support unique identifiers.
  2884.  
  2885.          The PARTIAL command is new in IMAP2bis.  If this command causes
  2886.          a BAD response, then the client should use the appropriate
  2887.          FETCH command and ignore the unwanted data.
  2888.  
  2889.          IMAP2bis client implementations must accept all responses and
  2890.          data formats documented in this specification, including those
  2891.          labeled as obsolete.  This includes the COPY and STORE
  2892.          unsolicited responses and the old format of dates and times.
  2893.  
  2894.          Older server implementations may not provide a way to set flags
  2895.          on APPEND.  Client implementations which receive a BAD response
  2896.          to an APPEND command with flags should retry the command
  2897.          without flags.
  2898.  
  2899.          Older server implementations may not preserve flags on COPY.
  2900.          Some server implementations may not permit the preservation of
  2901.          certain flags on COPY or their setting with APPEND as site
  2902.          policy.  Older server implementations may attempt to preserve
  2903.          the internal date on COPY, and may cause a mailbox to be
  2904.          ordered in other than strictly ascending internal date/time
  2905.          order.  Client implementations should not depend on any of
  2906.          these behaviors.
  2907.  
  2908.          Older server implementations may send a TRYCREATE special
  2909.          information token inside a separate unsolicited OK response
  2910.  
  2911.  
  2912.  
  2913. Crispin                                                        [Page 52]
  2914.  
  2915. Internet Draft                  IMAP2bis                October 27, 1993
  2916.  
  2917.  
  2918.          instead of inside the NO response.
  2919.  
  2920.       IMAP2bis server interoperability with old clients
  2921.  
  2922.       In general, there should be no interoperation problem between a
  2923.       server conforming to this specification and a well-written client
  2924.       that conforms to an earlier specification.  Known problems are
  2925.       noted below:
  2926.  
  2927.          Clients written to use undocumented private server extensions
  2928.          that are not in any published specification may work poorly
  2929.          with server implementations that do not have those extensions.
  2930.  
  2931.          Poor wording in the description of the CHECK command in earlier
  2932.          specifications implied that a CHECK command is the way to get
  2933.          the current number of messages in the mailbox.  This is
  2934.          incorrect.  A CHECK command does not necessarily result in an
  2935.          EXISTS response.  Clients must remember the most recent EXISTS
  2936.          value sent from the server, and should not generate unnecessary
  2937.          CHECK commands.
  2938.  
  2939.          An incompatibility exists with COPY in IMAP2bis.  COPY in
  2940.          IMAP2bis servers does not automatically create the destination
  2941.          mailbox if that mailbox does not already exist.  This may cause
  2942.          problems with old clients that expect automatic mailbox
  2943.          creation in COPY.
  2944.  
  2945.          The PREAUTH unsolicited response is new in IMAP2bis.  It is
  2946.          highly unlikely that an old client would ever see this
  2947.          response.
  2948.  
  2949.          The COPY unsolicited response is obsolete.  Old clients must
  2950.          not depend on receiving this response.
  2951.  
  2952.          The STORE unsolicited response is obsolete.  Old clients must
  2953.          not object to receiving a FETCH response instead of this
  2954.          response.
  2955.  
  2956.          The format of dates and times has changed.  Old clients should
  2957.          accept a four-digit year instead of a two-digit year, and a
  2958.          signed four-digit timezone value instead of a timezone name.
  2959.          In particular, client implementations must not treat a
  2960.          date/time as a fixed format string and assumed that the time
  2961.          begins at a particular octet.
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969. Crispin                                                        [Page 53]
  2970.  
  2971. Internet Draft                  IMAP2bis                October 27, 1993
  2972.  
  2973.  
  2974. Acknowledgements
  2975.  
  2976.    Bill Yeager and Rich Acuff contributed invaluable suggestions in the
  2977.    evolution of IMAP2 from the original IMAP.  James Rice pointed out
  2978.    several ambiguities in the previous IMAP2 specification.
  2979.  
  2980.    My colleagues on the Pine team -- Steve Hubert, Laurence Lundblade,
  2981.    David Miller, and Mike Seibel -- worked long and hard to create a
  2982.    fantastic email user agent with worldwide popularity.  Without their
  2983.    efforts, IMAP2 would have languished in obscurity.  Terry Gray, our
  2984.    boss, provided much-needed moral support and guidance, while refusing
  2985.    to let us get away with "good enough" when "great" was possible.
  2986.  
  2987.    John G. Myers and Chris Newman carefully examined the formal grammar
  2988.    and identified numerous mistakes and omissions in the drafts of this
  2989.    specification.  They also provided invaluable input towards the
  2990.    overall architecture of the present protocol, and endured long
  2991.    meetings to reach the present protocol.
  2992.  
  2993.    The present protocol would not have come into existence without the
  2994.    assistance of the rest of the IETF IMAP2 working group, in particular
  2995.    Ned Freed and Adam Treister.
  2996.  
  2997.    Any mistakes, flaws, or sins of omission in this IMAP2bis protocol
  2998.    specification are, however, strictly my own; and the mention of any
  2999.    name above does not imply an endorsement.
  3000.  
  3001. Security Considerations
  3002.  
  3003.    Security issues are discussed in this memo only as far as
  3004.    authentication to access a server are concerned.
  3005.  
  3006. Author's Address
  3007.  
  3008.    Mark R. Crispin
  3009.    Networks and Distributed Computing, JE-30
  3010.    University of Washington
  3011.    Seattle, WA  98195
  3012.  
  3013.    Phone: (206) 543-5762
  3014.  
  3015.    EMail: MRC@CAC.Washington.EDU
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025. Crispin                                                        [Page 54]
  3026.  
  3027.  
  3028.